I was wondering if it’s possible to add :conditions to an association,
such that the conditions reference variables that need to be re-
evaluated before each query?
When I tried an example binding a date column to Time.now, the time
didn’t change with each query. Instead, it continued using the
initial value of Time.now from when the class loaded.
When I tried an example binding a date column to Time.now, the time
didn’t change with each query. Instead, it continued using the
initial value of Time.now from when the class loaded.
You can interpolate these things, but as you found
has_many :foos, :conditions => “#{xyz}”
doesn’t work: this statement is ran at class load and so the string is
interpolated