On Tue, Oct 11, 2011 at 12:15 PM, Shanison <lxsh...@gmail.com> wrote:
> You have the following application helper
> module ApplicationHelper
>   def method_a
>   end
> end
> Then if you have other helper
> module OtherHelper
>   def b
>    method_a # i can call method a here
>   end
> end
> I am not sure how this actually works since module has not inheritance. So
> my question is if I didn't extend the applicationhelper module, but create a
> new module for it, let's say UserHelper. Then in any other helper module, i
> need to include this UserHelper module if the helper module needs to use
> some of the codes in it. Hope i get myself clear.

Have you tried my suggestion?
Just make another helper and include it in ApplicationController.

Here's a simple irb session exemplifying what happens if you add a
module to a class after the class is defined:

$ irb
>> module Greeter
>>   def hello
>>     'hello'
>>     end
>>   end
=> nil
>> class Thing
>>   include Greeter
>>   end
=> Thing
>> module More
>>   def more
>>     "more with #{hello}"
>>     end
>>   end
=> nil
>> Thing.class_eval { include More }
=> Thing
>> thing = Thing.new
=> #<Thing:0x101a6e008>
>> thing.hello
=> "hello"
>> thing.more
=> "more with hello"
>>





-- 
OOP, DCI, and Ruby
http://www.saturnflyer.com/blog/jim/2011/10/04/oop-dci-and-ruby-what-your-system-is-vs-what-your-system-does/

Jim Gay
Saturn Flyer LLC
http://www.saturnflyer.com
571-403-0338

Reply via email to