Am I missing something in Active record, or is there a plug-in available which easily allows to use the ''dot-notation'' in deeply linked (that is, more then one link away) associations. Suppose I want to count the posts in a blog of a certain user, can I write something like :condition :post.blog.user.name = ? Merg --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Merg: I think that you might want to try this this. I don''t know if this will work or not, but this is what I would experiment with: In your post model define a new method called ''comments_by_user'' #--------------- #post.rb class post < ActiveRecord::Base has many :comments belongs_to :user def comments_by_user(user) comments = Comment.find(:conditions => ["user_id = ? and post_id = ?", user.id, self.id]) end end #---- Invoke like this in your views: <%= post.comments_by_user(user).count-%> Lemme know if it works for you. -Elliott www.elliottblatt.com -- 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-/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?hl=en -~----------~----~----~----~------~----~------~--~---