<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>def Tenako.blog () end &#187; plugins</title>
	<atom:link href="http://blog.tenako.com/tag/plugins/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tenako.com</link>
	<description></description>
	<lastBuildDate>Sun, 10 Jul 2011 10:15:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Rails: Orden de carga de los plugins</title>
		<link>http://blog.tenako.com/2008/10/19/rails-orden-carga-plugins/</link>
		<comments>http://blog.tenako.com/2008/10/19/rails-orden-carga-plugins/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 16:57:43 +0000</pubDate>
		<dc:creator>farruco</dc:creator>
				<category><![CDATA[programacion]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[orden]]></category>
		<category><![CDATA[plugins]]></category>

		<guid isPermaLink="false">http://blog.tenako.com/?p=35</guid>
		<description><![CDATA[madtrick:~/programacion/ror/diary madtrick$ ruby script/server webrick =&#62; Booting WEBrick... /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1667:in `method_missing': undefined local variable or method `acts_as_authorizable' for #&#60;Class:0x336e194&#62; (NameError) from /Users/madtrick/programacion/ror/diary/app/models/user.rb:21 from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_without_new_constant_marking' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_file' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:214:in `load_file' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:95:in `require_or_load' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:60:in `depend_on' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:456:in `require_dependency' from /Users/madtrick/programacion/ror/diary/vendor/plugins/authentication_system/lib/authentication_system.rb:1 from /opt/local/lib/ruby/vendor_ruby/rubygems/custom_require.rb:27:in `gem_original_require' from /opt/local/lib/ruby/vendor_ruby/rubygems/custom_require.rb:27:in `require' from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require' ... Eso [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">madtrick:~<span style="color: #000000; font-weight: bold;">/</span>programacion<span style="color: #000000; font-weight: bold;">/</span>ror<span style="color: #000000; font-weight: bold;">/</span>diary madtrick$ ruby script<span style="color: #000000; font-weight: bold;">/</span>server webrick
=<span style="color: #000000; font-weight: bold;">&gt;</span> Booting WEBrick...
<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activerecord-2.1.0<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_record<span style="color: #000000; font-weight: bold;">/</span>base.rb:<span style="color: #000000;">1667</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>method_missing<span style="color: #ff0000;">': undefined local variable or method `acts_as_authorizable'</span> <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #666666; font-style: italic;">#&lt;Class:0x336e194&gt; (NameError)</span>
        from <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>madtrick<span style="color: #000000; font-weight: bold;">/</span>programacion<span style="color: #000000; font-weight: bold;">/</span>ror<span style="color: #000000; font-weight: bold;">/</span>diary<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>models<span style="color: #000000; font-weight: bold;">/</span>user.rb:<span style="color: #000000;">21</span>
        from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activesupport-2.1.0<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_support<span style="color: #000000; font-weight: bold;">/</span>dependencies.rb:<span style="color: #000000;">215</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>load_without_new_constant_marking<span style="color: #ff0000;">'
        from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:215:in `load_file'</span>
        from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activesupport-2.1.0<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_support<span style="color: #000000; font-weight: bold;">/</span>dependencies.rb:<span style="color: #000000;">354</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>new_constants_in<span style="color: #ff0000;">'
        from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:214:in `load_file'</span>
        from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activesupport-2.1.0<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_support<span style="color: #000000; font-weight: bold;">/</span>dependencies.rb:<span style="color: #000000;">95</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>require_or_load<span style="color: #ff0000;">'
        from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:60:in `depend_on'</span>
        from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.8</span><span style="color: #000000; font-weight: bold;">/</span>gems<span style="color: #000000; font-weight: bold;">/</span>activesupport-2.1.0<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>active_support<span style="color: #000000; font-weight: bold;">/</span>dependencies.rb:<span style="color: #000000;">456</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>require_dependency<span style="color: #ff0000;">'
        from /Users/madtrick/programacion/ror/diary/vendor/plugins/authentication_system/lib/authentication_system.rb:1
        from /opt/local/lib/ruby/vendor_ruby/rubygems/custom_require.rb:27:in `gem_original_require'</span>
        from <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>ruby<span style="color: #000000; font-weight: bold;">/</span>vendor_ruby<span style="color: #000000; font-weight: bold;">/</span>rubygems<span style="color: #000000; font-weight: bold;">/</span>custom_require.rb:<span style="color: #000000;">27</span>:<span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span>require<span style="color: #ff0000;">'
        from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'</span>
...</pre></div></div>

<p>Eso fue lo que me encontre hoy al ir a probar unas cosillas en Rails.</p>
<p>El problema deriva del orden en el que se cargan los plugins residentes en <em>$RAILS_ROOT/vendor/plugins</em>, que a parecer es lexicografica, con lo cual yo me encontraba en la situacion de que el plugin A hacia uso del modelo M pero a su vez este modelo hacia uso de un metodo <a href="http://www.juixe.com/techknow/index.php/2006/06/15/mixins-in-ruby/" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.juixe.com');" target="_blank">&#8220;mixeado&#8221;</a> en ActiveRecord::Base por el plugin B.</p>
<p>Por lo tanto, como A se cargaba antes que B ya teniamos montado el belen.</p>
<p>Tras preguntarle al señor google que como arreglabamos este desaguisado, este primero me dijo que ya habia mas gente con este problema allá por el 2006 (<a href="http://dev.rubyonrails.org/ticket/5468" onclick="javascript:pageTracker._trackPageview('/outbound/article/dev.rubyonrails.org');" target="_blank">1</a>) y (<a href="http://dev.rubyonrails.org/ticket/6418" onclick="javascript:pageTracker._trackPageview('/outbound/article/dev.rubyonrails.org');" target="_blank">2</a>) y que finalmente la solucion por la que se opto fue la <a href="http://dev.rubyonrails.org/changeset/7531" onclick="javascript:pageTracker._trackPageview('/outbound/article/dev.rubyonrails.org');" target="_blank">siguiente</a> :</p>
<p>En environment.rb ponemos config.plugins = {:plugin1,:plugin2,:all} pudiendo controlar asi, el orden en el que se carga dichos plugins,cuales se cargan, etc.El simbolo :all, evidentemente se utiliza para cargar todos los demas plugins.</p>
<p><strong>Actualizacion:</strong></p>
<p>Soy algo cortito, si me hubiera molestado en leerme lo que ponia en environment.rb no habria tenido ningun problema.Extraido de environment.rb:</p>
<blockquote><p># Only load the plugins named here, in the order given. By default, all plugins<br />
  # in vendor/plugins are loaded in alphabetical order.<br />
  # :all can be used as a placeholder for all plugins not explicitly named</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.tenako.com/2008/10/19/rails-orden-carga-plugins/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

