I know a few people who have been bitten by using this code in a class
context:

{:conditions => ['companies.created_at > ?', 7.days.ago.to_s(:db)}

If you use that with a has_many, that time code gets evaluated
immediately and baked into the finder.

Unless I'm wrong, you used to be able to use single-quotes to delay
evaluation, e.g. '#{7.days.ago.to_s(:db)}'. I say used to, because
today i was trying it and it wasn't working. Even if it still worked,
really, that's just disgusting.

So I wrote a quick patch that lets you pass a lambda to :conditions
and it will be evaluated at bind time.

http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/427-bind-lambdas-in-conditions

It seemed to work in my convoluted test case. Feedback?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to