Should there be trouble w/has_many_polymorphs in a plugin?

Folks,

As much as I like generators, I'd greatly prefer to just throw my
has_many_polymorphs tagging and commenting engines into projects as
plugins. However, after transplanting my tag.rb and tagging.rb files
into the lib folder of a 'has_many_tags' plugin and adding the
obligatory plugin requirements (init.rb and an include in
environment.rb), I'm not having any luck. All I get is a white screen
courtesy of a call to .tag_list (incidentally - anyone know how to get
view exceptions to actually show up instead of just a white screen?)

Due to said white screen and lack of exception data (in logs or
anywhere), I've hit a bit of a road block. Does anyone have any
suggestions, or know if there's some kind of hackery required to make
has_many_polymorphs and plugins happy together?

Thanks,
Mike

Note - even a 'yes, I've successfully used has_many_polymorphs in a
plugin and/or engine' would be beneficial. A little confirmation might
just boost me back into hardcore troubleshooting mode... :slight_smile:

Note - even a 'yes, I've successfully used has_many_polymorphs in a
plugin and/or engine' would be beneficial. A little confirmation might
just boost me back into hardcore troubleshooting mode... :slight_smile:

I know nothing about has_many_polymorphs, but here's a random guess: remove your plugin from Dependencies.load_once_paths (I usually do this in the init.rb of the plugin).
Otherwise really weird stuff can happen, because your plugin isn't reloaded, but models it references are reloaded.

Fred

Frederick Cheung wrote:

Note - even a 'yes, I've successfully used has_many_polymorphs in a
plugin and/or engine' would be beneficial. A little confirmation might
just boost me back into hardcore troubleshooting mode... :slight_smile:

I know nothing about has_many_polymorphs, but here's a random guess:
remove your plugin from Dependencies.load_once_paths (I usually do
this in the init.rb of the plugin).
Otherwise really weird stuff can happen, because your plugin isn't
reloaded, but models it references are reloaded.

Fred

Hmmm... tried removing either & both plugins (has_many_polymorphs and my
plugin) out of the load_once_paths, but it didn't fix the issue.
'respond_to' shows that the tagging methods are in fact present in my
plugin models, but something's going wrong in the internals. Guess I'll
try and dig deeper.

Load_once_path should help with the debugging process quite a bit,
though - didn't know about that one, so thank you for the tip!

FYI to any folks who need to remove anything from load_once_path - if
'Dependencies.load_once_paths.delete xxxx' is giving you trouble (I
couldn't get my paths to match dynamically due to issues with
RAILS_ROOT), use:
Dependencies.load_once_paths.delete_if { |e| e.match(/plugin_regex/) }
etc.

That way you're guaranteed it will delete properly.

Mike