实际上,我正在为模型多->多做一个项目。我需要找到当前用户的所有积分/设备/项目(我认为只有两列(id & score)的表积分是没用的,所以我将此表合并到连接表)。
我收到此错误:
SystemStackError in Users#show
Showing app/views/shared/_credit.html.erb where line # raised:
stack level too deep
和两个模型:
class **Credit** < ActiveRecord::Base
attr_accessible :created_at, :credit_id, :device_id, :project_id, :score, :user_id
belongs_to :device
belongs_to :user
belongs_to :project
belongs_to :score
end
class **User** < ActiveRecord::Base
has_many :credit
has_many :credit, :through => :credit, foreign_key: "user_id", dependent: :destroy
end
谢谢 !
最好的。