Stuart Hungerford
2005-Aug-16 10:08 UTC
Best way to access constants in application_helper.rb from views?
Hi, I''m using the application_helper.rb file to create some useful functions for generating links by name. I understand that functions defined in this file are available to all views, but what about constants defined in that module? Is there a best practice approach for doing this other than accessing each constant via ApplicationHelper::FOO? Stu
Steve Downey
2005-Aug-16 14:39 UTC
Re: Best way to access constants in application_helper.rb from views?
Stuart Hungerford wrote:> Hi, > > I''m using the application_helper.rb file to create some useful functions > for generating links by name. > > I understand that functions defined in this file are available to all > views, but what about constants defined in that module? Is there a > best practice approach for doing this other than accessing each constant > via ApplicationHelper::FOO? >You might consider wrapping the constant with a method. That way (for example) if instead of a constant you now caclulate the value, you only have to change the method in one place rather than change each reference to the constant.