我想在rails 3中加入更多三个表
我的代码
class offer < ActiveRecord::Base belongs_to :user has_many :usercomments, :dependent => :destroy has_many :comments, :through => :usercomments, :dependent => :destroy end
class User < ActiveRecord::Base has_many :usercomments, :dependent =>:destroy has_many :comments,:through => :usercomments, :dependent => :destroy has_many :offers, :dependent => :destroy end
class Usercomment < ActiveRecord::Base belongs_to :user belongs_to :comment belongs_to :offer end
class Comment < ActiveRecord::Base has_one :usercomment, :dependent => :destroy has_one :offer, :through => :usercomments has_one :user, :through => :usercomments end
模式
create_table "offers", :force …