Re: [Rails] Including associations with dynamic conditions

2011-07-13 Thread Frederick Cheung
On 13 Jul 2011, at 20:23, Vijay Dev wrote: > Given a school model and a student model with the school having a has_many > relation to student: > > has_many :students, :conditions => proc { "year_id=#{send(:active_year_id)}" > } > > where active_year_id is a method defined in the school mo

[Rails] Including associations with dynamic conditions

2011-07-13 Thread Vijay Dev
Given a school model and a student model with the school having a has_many relation to student: has_many :students, :conditions => proc { "year_id=#{send(:active_year_id)}" } where active_year_id is a method defined in the school model, I'm encountering an error that "active_year_id is undefi