ApplicationHelper not available to views and models?

stuff placed in application_helper.rb is only available to your
Views / Helpers.

If you want a constant to be available to everything put it in your
config/environment.rb file

Or if you only need it in your controllers controller/application.rb.

Just models you can create a module in your /lib folder and mix it in
with ActiveRecord::Base to make it available to all your models.

I know you wanted them all but I figured I'd just cover the others as
a bonus.

Hope I helped,


now I may get corrected or put down for this, but I have put some
constants into my models where I wanted to have them available for
mapping view information against model attributes.

If you want some constants available globally (something I have been
thinking about myself), but don't view them as being Environment type
variables, then could you not create a model Class to contain the
models and then reference them by that class. That would seem to me
to be a fairly clean approach, but someone may say that this goes
against the 'rules'? I would be interested to know.


In the application controller you could put this line of code:
'include ApplicationHelper' in order to be able to use the helper
methods in the controller. Another approach is to put your code in
the /lib folder and do a require 'filename' in the controller or

I'd suggest not just wholesale-including ApplicationHelper into
ApplicationController. Any public methods in controllers in Rails end
up being exposed as actions, which may have inadvertent side effects,
unless you call hide_action on them, and it's generally better
practice to separate view and controller.

- Gabriel