# Rails plugins that use other plugins - why is does this seem impossible?

**URL:** <https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060>\
**Category:** Rails\
**Created:** [January 15, 2008, 4:15am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060 "2008-01-15T04:15:42Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 4:15am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/1 "2008-01-15T04:15:42Z")

</div>

OK, probably the most frustrated I’ve ever been with Rails. If I don’t  
figure this out, I’m going to, um… try again tomorrow.

I’m simply trying to create a plugin. I did the ./script/generate  
plugin MY\_NEW\_PLUGIN and wha-hoo great! Well, not really…

This plugin uses other plugins. For example, acts\_as\_list,  
acts\_as\_money etc… How the heck to I get these plugins loaded and  
ready to be used? I’ve put them here:

main-app/vendor/plugins/MY\_NEW\_PLUGIN/vendor/plugins/

I’ve added all of their paths and lib paths to the config.load\_paths  
variable, I’ve tried loading (require and load) their init.rb files.  
And no matter what, it’s pretty obvious that the paths aren’t setup  
correctly. I’ve even tried

$: \<\< ‘path/to/acts\_as\_list’  
$: \<\< ‘path/to/acts\_as\_list/lib’

I’d like to be able to specify additional load\_paths in init.rb and  
then use config.plugins - seems logical.?

Ahhhhhhoar!!!

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 5:16am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/2 "2008-01-15T05:16:28Z")

</div>

Hi Ryan,

I tried irc, which is totally foreign to me. What is nickserv? Am I  
supposed to signup for membership?

On Jan 14, 10:59 pm, “Ryan B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> perhaps just a require ‘acts\_as\_list’ with a rescue with an error message  
> will do it, probably.

Well, my plugin, will come with acts\_as\_list. So I just want to be  
able to load it correctly. When my plugins init.rb file is loaded, I’m  
pretty sure that $LOAD\_PATH is already set. So using config.load\_paths  
doesn’t seem to do anything. And the same with config.plugin\_paths.

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 5:00am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/3 "2008-01-15T05:00:07Z")

</div>

perhaps just a require ‘acts\_as\_list’ with a rescue with an error  
message  
will do it, probably. There’s most likely a better way to go about it,  
and  
why not ask the #rubyonrails irc channel in [irc.freenode.net](http://irc.freenode.net)? Their  
responses can be more instantaneous than here most times.

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 5:41am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/4 "2008-01-15T05:41:01Z")

</div>

Oh yeah I should’ve mentioned. You have to have a registered name before  
you  
go into the channel so that random people can’t spam it. Just type /msg  
nickserv help register and follow the instructions.

On Jan 15, 2008 2:45 PM, goodieboy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Well, my plugin, will come with acts\_as\_list. So I just want to be  
> able to load it correctly. When my plugins init.rb file is loaded, I’m  
> pretty sure that $LOAD\_PATH is already set. So using config.load\_paths  
> doesn’t seem to do anything. And the same with config.plugin\_paths.
> 
> > There’s most likely a better way to go about it, and  
> > why not ask the #rubyonrails irc channel in [irc.freenode.net](http://irc.freenode.net)? Their  
> > responses can be more instantaneous than here most times.

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 6:48am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/5 "2008-01-15T06:48:47Z")

</div>

Cool, thank you 🙂

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 9:49am UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/6 "2008-01-15T09:49:02Z")

</div>

Is this rails 1.2 or rails 2.0? Quite a bit changed about plugin  
loading in between.

Fred

---

<div class="post-metadata">

**Author:** ![goodieboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecc23a/32.png) [@goodieboy](https://www.ruby-forum.com/u/goodieboy)\
**Post date:** [January 15, 2008, 3:27pm UTC](https://www.ruby-forum.com/t/rails-plugins-that-use-other-plugins-why-is-does-this-seem-impossible/126060/7 "2008-01-15T15:27:53Z")

</div>

Rails 2.0.2

I found a way to make it all work - not the correct, Rails way though.  
It’s not what I would have expected. I thought I could do everything I  
needed inside of the init.rb file. But from the way it seems, at that  
point it’s too late to add to the $LOAD\_PATH so adding plugins to  
config.plugins inside of init.rb doesn’t work. Or am I wrong? I tried  
many different things.

I’ll come clean now; this plugin is really another Rails app. it has  
controllers, models, views, routes etc… I wanted to be able to reuse  
this inside of client apps. And maintain only one code base for the  
“plugin” (updatable via svn etc.) I wanted it to work like Django apps  
do. And I achieved a lot of that by initializing my plugin inside of  
the Rails::Initialize.run block:

Rails::Initialize.run do |config|  
MySuperPluginThatsReallyAnApp::init(config)  
end

Basically, I add a bunch of paths (load\_paths and load\_once\_paths),  
include my plugins etc… Now I can use that one line in my main apps’  
environment.rb file, and without doing anything have a full blown app  
running without doing any extra coding. And thanks to the load paths,  
I can override any view, model etc… just by creating the file in the  
app that’s using the “plugin”. Very handy. I have to manually copy  
routes, and public folder items, but that’s OK. I want to be able to  
override those aspects anyway.

The big downside is that I can’t do cool, builtin things with Rake,  
and testing. So I’m going to keep trying to get this to work the  
correct, Rails 2.0 plugin way.

Feedback anyone?

On Jan 15, 3:48 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
