On 15 April 2010 13:58, Rahul Mehta <[email protected]> wrote:
> i have two module both are joined by HABTM name are tags and
> content_masters
>
> i have content_master .id and i want to get all the content_masters
> which are with the same tag as that id has .
>
> means if my content_master .id=1 is associated with tag_id 1,2
> than i want the listing of all the content_master with tag_id=1,2

Do you really have just the id of the content master or do you have
the object itself? If you have a content_master in @content_master
then the associated tags are available as an array in
@content_master.tags.
If you only have the id of the content master then something like
@tags = Tag.find( :all, :include => 'content_masters', :conditions =>
['content_masters.id = ?', content_master.id] )

Colin

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to