Topic: has_many belongs_to issue

I have a users(id,name) and a posts(id,content,user_id, user_ip).
each user has_many :posts and each Post belongs_to :user
I would like to get all users which has posted with user_ip = '127.0.0.1'

what's the best way to get that?

thanx in advance

Pat

Re: has_many belongs_to issue

Try this:

@users = User.find(:all, :include => :posts, :conditions => "posts.user_ip='127.0.0.1'")

Railscasts - Free Ruby on Rails Screencasts

Re: has_many belongs_to issue

thanx