Active record joins in rails 3.1 -



Active record joins in rails 3.1 -

trying homecoming comments associated articles written particular user. next code gives me error:

undefined method `joins' #<user:0x000001042c8bc0>

under rails 3.1

class user has_many :articles def comments self.joins(:articles => :comments) end end

you want has_many :through here.

class user has_many :articles has_many :comments, :through => :articles end

ruby-on-rails ruby-on-rails-3 activerecord join

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -