Hi folks
I have the following construct as part of my ApplicationHelper to
output the name of season for a time object:
module ApplicationHelper
SEASONS =
{2=>''Winter'',5=>''Spring'',8=>''Summer'',11=>''Fall''}
def art_season_tag (time)
''<span
class="season">''+SEASONS[time.month].downcase+''</span>''
end
end
It works as planned except that everytime I request an action in
development mode my fastcgi process complains that the SEASONS
constant is already initalized:
FastCGI-stderr: ...app/helpers/application_helper.rb:3: warning:
already initialized constant SEASONS
Of course this makes perfect sense because one cannot re-define or
change a constant by design. I also realize that the issue will
disappear in production mode as rails won''t be reloading all files
everytime a request is made.
I suppose I could put it in config.rb but it feels right to me to have
SEASONS defined in the ApplicationHelper as it is the only place in my
application where the constant is referenced. I would also prefer to
keep the SEASONS definition close to the methods that use it so that I
can easily cut-n-paste the logic into another application.
Craig Davey