Q:

How do I call a method inside ApplicationHelper from my Model?

# application_helper.rb

def do_some_stuff
   ...
end

# my_model.rb

def my_model_method
   # I want to call the method "do_some_stuff" here, how exactly?
end

Obviously, I can't just call do_some_stuff, since it would tell me that the model does not have this method.

A:

You can accomplish this by adding the following line to your model file:
include ActionView::Helpers

Now, you may want to reconsider placing your helper method somewhere else (e.g. the model, or a mixin module), but use the above line to do what you've asked for.

