When You Want To Pass A Condition To A Model From Dot Notation

I really don't know if the subject made any sense! :slight_smile:

Basically I do the following

@user.tags.each do |tag|
   ...
end

Now I want to limit which tags associated to a user are returned. I
have a category associated with each tag. So for instance I just want
to a user's tags which have a category = location. Can I do something
like that? :slight_smile:

Thanks for your help :-).

If you are willing to take a db hit I’m pretty sure this will work.

@user.tags.find(:all, :conditions => [“category = ?”, location]).each do |tag|

end

Hopefully that helps,
Tyler Prete

That makes perfect sense thanks. :slight_smile: