Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't say for sure that this is the problem in Rails, but my guess is that it's not far off the mark. The "fix" at the end may not be easily applied in the case of a Rails app.</p> <p>First, a directory listing:</p> <pre><code>&gt; ls -R .: bar_then_foo.rb bar_then_foo2.rb foo_then_bar.rb lib_foo lib_fubar ./lib_foo: helper.rb ./lib_fubar: helper.rb </code></pre> <p>The helper modules:</p> <pre><code>&gt; cat lib_foo/helper.rb module Helper def foo puts "foo" end def bar puts "bar" end end &gt; cat lib_fubar/helper.rb module Helper def foo puts "foo-bar" end end </code></pre> <p>The Ruby code:</p> <pre><code>&gt; cat bar_then_foo.rb $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_fubar' $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_foo' require 'helper' class FoobieDoo include Helper end f = FoobieDoo.new f.foo f.bar &gt; cat foo_then_bar.rb $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_foo' $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_fubar' require 'helper' class FoobieDoo include Helper end f = FoobieDoo.new f.foo f.bar </code></pre> <p>And some output:</p> <pre><code>&gt; ruby bar_then_foo.rb foo bar &gt; ruby foo_then_bar.rb foo-bar foo_then_bar.rb:12: undefined method 'bar' for #&lt;FoobieDoo:0x1042e93c&gt; (NoMethodError) </code></pre> <p>So Ruby is searching $LOAD_PATH from the end and stops as soon as it finds a match.</p> <p>Let's try something else:</p> <pre><code>&gt; cat bar_then_foo2.rb $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_fubar' $LOAD_PATH.unshift File.dirname(__FILE__) + '/lib_foo' require 'helper' load "lib_fubar/helper.rb" class FoobieDoo include Helper end f = FoobieDoo.new f.foo f.bar &gt; ruby bar_then_foo2.rb foo-bar bar </code></pre> <p>Desired result?</p> <p>Maybe you can modify <code>app/helpers/application_helper.rb</code> to search for other application_helper.rb files in the LOAD_PATH and load them?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload