John Kopanas
2006-Sep-09 18:28 UTC
When You Want To Pass A Condition To A Model From Dot Notation
I really don''t know if the subject made any sense! :-) 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? :-) Thanks for your help :-). -- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Tyler Prete
2006-Sep-09 19:33 UTC
Re: When You Want To Pass A Condition To A Model From Dot Notation
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 On 9/9/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I really don''t know if the subject made any sense! :-) > > 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? :-) > > Thanks for your help :-). > > -- > John Kopanas > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
John Kopanas
2006-Sep-09 20:08 UTC
Re: When You Want To Pass A Condition To A Model From Dot Notation
That makes perfect sense thanks. :-) On 9/9/06, Tyler Prete <psyonic-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 > > > On 9/9/06, John Kopanas <kopanas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I really don''t know if the subject made any sense! :-) > > > > 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? :-) > > > > Thanks for your help :-). > > > > -- > > John Kopanas > > john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org > > > > > > > > > > > > >-- John Kopanas john-Iau1QiYlxLpBDgjK7y7TUQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---