module Constants
FOO = %w( tastes great)
BAR = %w( less filling)
end
I'm able to access the constants fine in my Model, but I'm also using
them to populate select boxes in a view and can't figure out how to
make them available to the view.
I've tried:
require 'constants'
class ApplicationController < ActionController::Base
include Constants
....
end
as well as the same thing in the specific controller whose method is
calling the offending action.
Any advice on where to require the module? Thanks,
module Constants
FOO = %w( tastes great)
BAR = %w( less filling)
end
I'm able to access the constants fine in my Model, but I'm also using
them to populate select boxes in a view and can't figure out how to
make them available to the view.
I've tried:
require 'constants'
class ApplicationController < ActionController::Base
include Constants
....
end
as well as the same thing in the specific controller whose method is
calling the offending action.
Any advice on where to require the module? Thanks,
It's not to do with requiring (you can get rid of that require
'constants') it's to do with where the module is included.
You could just write Constants::FOO in your view.
Alternatively,
class ApplicationController < ActionController::Base
include Constants
helper Constants
end
might work (but slightly abusing the helper method)