<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>OnRails.org: Managing Rails Plugins dependencies</title>
    <link>http://onrails.org/articles/2006/03/04/managing-rails-plugins-dependencies</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Ruby On Rails and related matters.</description>
    <item>
      <title>Managing Rails Plugins dependencies</title>
      <description>&lt;p&gt;Rails has a nice plugin system allowing to add common code to a project. A plugin should really be independent from any other plugins. But we also use plugins to share code among different projects we are working on and our code depends on existing plugins.  The Rails development team want&amp;#8217;s to keep the plugin system simple and didn&amp;#8217;t provide an explicit way to handle these dependencies, which I believe is a good decision.  There is a solution. Simply name the plugins in order off the dependencies you have.  Let&amp;#8217;s assume you want to add &amp;#8220;my_very_own_plugin&amp;#8221; plugin that depends on the enumation_mixin,  then simply organize the /vendor/plugins folder as follows, et Voila!:.&lt;/p&gt;


&lt;pre&gt;
/myrailsapp
    /vendor
        /plugins
            /01_acts_as_taggable
            /01_enumations_mixin 
            /01_acts_as_versioned
            /02_my_very_own_plugin
&lt;/pre&gt;

	&lt;p&gt;If we look at the Rails::Initializer we can see why this works. Note, this is only an extract of the full class that Rails provides to bootstrap your rails applicaton. The sort on line 4 here after allows this trick.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;table class="typocode_linenumber"&gt;&lt;tr&gt;&lt;td class="lineno"&gt;
&lt;pre&gt;
1
2
3
4
5
6
7
8
&lt;/pre&gt;
&lt;/td&gt;&lt;td width="100%"&gt;&lt;pre&gt;&lt;code class="typocode_ruby "&gt;&lt;span class="keyword"&gt;module &lt;/span&gt;&lt;span class="module"&gt;Rails&lt;/span&gt;
  &lt;span class="keyword"&gt;class &lt;/span&gt;&lt;span class="class"&gt;Initializer&lt;/span&gt;
    &lt;span class="keyword"&gt;def &lt;/span&gt;&lt;span class="method"&gt;load_plugins&lt;/span&gt;
      &lt;span class="ident"&gt;find_plugins&lt;/span&gt;&lt;span class="punct"&gt;(&lt;/span&gt;&lt;span class="ident"&gt;configuration&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;plugin_paths&lt;/span&gt;&lt;span class="punct"&gt;).&lt;/span&gt;&lt;span class="ident"&gt;sort&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;each&lt;/span&gt; &lt;span class="punct"&gt;{&lt;/span&gt; &lt;span class="punct"&gt;|&lt;/span&gt;&lt;span class="ident"&gt;path&lt;/span&gt;&lt;span class="punct"&gt;|&lt;/span&gt; &lt;span class="ident"&gt;load_plugin&lt;/span&gt; &lt;span class="ident"&gt;path&lt;/span&gt; &lt;span class="punct"&gt;}&lt;/span&gt;
      &lt;span class="global"&gt;$LOAD_PATH&lt;/span&gt;&lt;span class="punct"&gt;.&lt;/span&gt;&lt;span class="ident"&gt;uniq!&lt;/span&gt;
    &lt;span class="keyword"&gt;end&lt;/span&gt;
  &lt;span class="keyword"&gt;end&lt;/span&gt;
&lt;span class="keyword"&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;</description>
      <pubDate>Sat, 04 Mar 2006 09:26:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:321740a4-4c6c-41d7-b42a-c1c1e1164942</guid>
      <author>Daniel Wanja</author>
      <link>http://onrails.org/articles/2006/03/04/managing-rails-plugins-dependencies</link>
      <category>Rails Tips</category>
    </item>
    <item>
      <title>"Managing Rails Plugins dependencies" by Doug</title>
      <description>&lt;p&gt;I just realized that you can explicitly load a plugin from within your plugin&amp;#8217;s init.rb by just calling load_plugin:&lt;/p&gt;


	&lt;p&gt;load_plugin &amp;#8216;vendor/plugins/acts_as_taggable&amp;#8217;&lt;/p&gt;


	&lt;p&gt;Little bit of a hack I suppose but it works.&lt;/p&gt;</description>
      <pubDate>Wed, 04 Jun 2008 01:02:57 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:2686ea55-1455-492c-abb1-d1bb9ffe43e5</guid>
      <link>http://onrails.org/articles/2006/03/04/managing-rails-plugins-dependencies#comment-3680</link>
    </item>
  </channel>
</rss>
