Wednesday, February 10, 2010

[Rails] Re: Parameterized ActiveRecord Associations: Any such thing?

On Feb 10, 7:27 pm, Erol Fornoles <erol.forno...@gmail.com> wrote:
>
> Named scopes are already sufficient for what you're trying to achieve:
>
> class Sprocket
>   named_scope :versioned, lambda { |version| {:conditions => {:version => version}} }
> end
>
> widget.sprockets.version(version).all(:conditions => callers_conditions)

Cool, I didn't know that the evaluated result (Array-like-thingy) of
an association could in turn be used to access named scopes w/in the
associated class. Works great.

Thanks.

--
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


Real Estate