My model, Widget.rb, has include ApplicationHelper and my instance methods have no trouble using any method defined in application_helper.rb
However, when I try to use one of the helper methods in any of my class methods such as
def self.send_broadcast(guid)
track_guids(guid) # defined in application_helper.rb
end
I get No Method error.
Is there some secret handshake to permit use of a ApplicationHelper method inside a class method?
ApplicationHelperis just a module:Now you should have access to the module methods from a class method. I’m not sure if you can both extend and include the same module though… not really sure what that’d do.
Edit to add:
I’m not sure what will happen if you try both extending and including the same module into the class. With
extendyou get the module included at the class-level, withincludeit is included at the instance-level. It might give you the methods at both class and instance if you do both… or it might die horribly. Give it a try?