# Plugin dependencies

**URL:** <https://www.ruby-forum.com/t/plugin-dependencies/170223>\
**Category:** Rails\
**Created:** [June 14, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/plugin-dependencies/170223 "2009-06-14T12:12:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tilt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tilt](https://www.ruby-forum.com/u/tilt)\
**Post date:** [June 14, 2009, 12:12pm UTC](https://www.ruby-forum.com/t/plugin-dependencies/170223/1 "2009-06-14T12:12:53Z")

</div>

Hi,

I’d like to rewrite a plugin called paperclipped\_assets that’s based on  
paperclip and provides a central model keeping all attachments.  
Unfortunately I need to require the class Attachment.rb of paperclip in  
paperclipped\_assets, which results in the following error

uninitialized constant HasPaperclippedAsset::InstanceMethods::Attachment

Is there something like a plugin\_require which I could use to make  
paperclipped\_assets know the paperclip classes? Or do I have to join the  
plugins to achieve this?

Thanks for your help!

Best regards

---

<div class="post-metadata">

**Author:** ![tilt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tilt](https://www.ruby-forum.com/u/tilt)\
**Post date:** [June 15, 2009, 10:25am UTC](https://www.ruby-forum.com/t/plugin-dependencies/170223/2 "2009-06-15T10:25:57Z")

</div>

You shouldn’t need to do anything, beyond some documentation to remind  
you (or others) that they need to install paperclip as well as your  
plugin.

The lib directories of all plugins are available before any plugin’s  
init.rb is evaluated, so your code should be able to refer to classes  
in other plugins without having to do anything special. You could  
certainly add a ‘require “attachment”’ statement somewhere in your  
code, just to be explicit.

- James

On Jun 14, 11:12 am, “Till B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![tilt](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/67e7ee/32.png) [@tilt](https://www.ruby-forum.com/u/tilt)\
**Post date:** [June 15, 2009, 10:34am UTC](https://www.ruby-forum.com/t/plugin-dependencies/170223/3 "2009-06-15T10:34:51Z")

</div>

On Jun 15, 9:25 am, James A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> You shouldn’t need to do anything, beyond some documentation to remind  
> you (or others) that they need to install paperclip as well as your  
> plugin.
> 
> The lib directories of all plugins are available before any plugin’s  
> init.rb is evaluated, so your code should be able to refer to classes  
> in other plugins without having to do anything special. You could  
> certainly add a ‘require “attachment”’ statement somewhere in your  
> code, just to be explicit.

It’s not completely inconceivable that you might need paperclip to be  
loaded first - if it ends being more than just requiring attachment.rb  
you wouldn’t want to find yourself effectively rewriting paperclip’s  
init.rb. If you explicitly name plugins then they are loaded in the  
specified in that order eg

config.plugins = [:paperclip, :my\_plugin]

maintaining such a list as you add plugins is annoying though (and I  
found myself adding a new plugin and spending 5 minutes wondering why  
it wasn’t working before remembering I hadn’t updated the list)

Luckily you can specify :all which represents all not explicitly named  
plugins eg

config.plugins = [:all, :my\_plugin] or

config.plugins = [:paperclip, :all]

Fred
