# Should there be trouble w/has\_many\_polymorphs in a plugin?

**URL:** <https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745>\
**Category:** Rails\
**Created:** [February 11, 2008, 7:15am UTC](https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745 "2008-02-11T07:15:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlopke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9de053/32.png) [@mlopke](https://www.ruby-forum.com/u/mlopke)\
**Post date:** [February 11, 2008, 7:15am UTC](https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745/1 "2008-02-11T07:15:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![mlopke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9de053/32.png) [@mlopke](https://www.ruby-forum.com/u/mlopke)\
**Post date:** [February 11, 2008, 9:07pm UTC](https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745/2 "2008-02-11T21:07:24Z")

</div>

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… 🙂

---

<div class="post-metadata">

**Author:** ![mlopke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9de053/32.png) [@mlopke](https://www.ruby-forum.com/u/mlopke)\
**Post date:** [February 11, 2008, 9:27pm UTC](https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745/3 "2008-02-11T21:27:29Z")

</div>

On 11 Feb 2008, at 20:07, Mike L. 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… 🙂

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

---

<div class="post-metadata">

**Author:** ![mlopke](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/9de053/32.png) [@mlopke](https://www.ruby-forum.com/u/mlopke)\
**Post date:** [February 13, 2008, 5:44am UTC](https://www.ruby-forum.com/t/should-there-be-trouble-w-has-many-polymorphs-in-a-plugin/128745/4 "2008-02-13T05:44:59Z")

</div>

Frederick C. wrote:

> On 11 Feb 2008, at 20:07, Mike L. 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… 🙂
> 
> 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
