Re: [Rails] Re: Including associations with dynamic conditions
On Thu, Jul 14, 2011 at 5:53 AM, Andrew Skegg <andrewskegg@me.com> wrote:
Vijay Dev <vijaydev.cse@...> writes:That smells like it belongs in a named scope on the School rather than on the
>
>
> 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)}" }
relationship.
I want school.students to always return students belonging to the active year. I chose this way so that I don't need to change too much of code.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home