Thats because the return value is part of the helper definition and the
definition is set when the app is loaded, normally one would evaluate the
result and this would be updated on every request, thats why your problem
seems strange, but is not strange is the default behavior, so what do you do
? I have to go to work now so i cant fully explain but you have to return a
lambda method if you want your result to be dynamic.
I'll show a common example with the model on rails 2
name_scope :recent ,:conditions=>{ :create_at => 2.months.ago}
^^ the 2 month ago is set on app load and not changed as long as you dont
restart the app, so a year from now will have the same value
name_scope :recent ,lambda {:conditions=>{ :create_at => 2.months.ago} }
^^ here the 2.month.ago is reevaluated on every call to the method
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.