association :conditions & instance-variable evaluation

Hello,

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?

e.g.: has_many :people, :conditions => "some_column = @some_instance_variable, revision_time > #{Time.now}," etc.

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.

Thanks, Tom

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

has_many :foos, :conditions => '#{xyz}'

should do the trick.

Fred