Aruna Chinnamuthu
2012-Feb-22 05:48 UTC
Collect users who posted items with ActsasTaggable on Tag in rails 3
I am using Rails 3 and Acts as taggable on in my application.
I am fetching the articles associated with the tag by
Article.tagged_with("tagname")
and
Blog.tagged_with("tagname")
Now i would like to collect all the users from the above i.e.., people
who are all posted articles and blogs with this tag Please suggest me..
--
Posted via http://www.ruby-forum.com/.
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer
2012-Feb-22 13:11 UTC
Re: Collect users who posted items with ActsasTaggable on Tag in rails 3
How do your Article and Blog models relate to the User model?
Assuming User has many Articles and Blogs you can simply do this:
user = User.find_by_whatever("something")
user.articles.tagged_with("tagname")
user.blogs.tagged_with("tagname")
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/o_2QQsAAolsJ.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.