Re: Re: Dynamic attribute-based finders

Mark Beattie
2005-11-04T07:45:37Z

On Friday 04 November 2005 3:07 pm, Mark Reginald James
wrote:
> I think what you want is:
>
> class A
>    has_and_belongs_to_many :bs
> end
>
> a = A.find(id)
> a.bs.find( :all, :conditions => ''...'' )
>
> or, if :conditions are empty, just "a.bs".

Nice one, thanks. I found you can also do:

A.find(id).bs

to skip a line of code. Thanks to the "Ruby" in Ruby on Rails.

Mark Beattie
Easy Schedule Management