> Haven't tried it, but maybe grouping on posts.id would do the right
> thing?
>
> --Matt Jones

Hello Matt, thanks for the answer. I've try it and it works fine
except when you call to "count" method later. I've solve it well:

scope :finded, lambda {|id| where(:id => id)}
scope :tagged, lambda {|tag_id|
select('posts.id').joins(:taggings).where(:taggings => {:tag_id =>
tag_id}) }

And then, for call the method, I do this:

@posts = Post.finded(Post.tagged(params[:tag_id]).uniq.map {|x| x.id})

The finded scope is for return an ActiveRecord array instead do the
common find method. Yes, it's not too smart solution but, for the
moment, it's working and while I'm trying to find a more clean
solution and I'm attentive for your answers and advices. Thanks!

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

Reply via email to