ruby-on-rails – rails:堆栈级别太深

实际上我正在为一个模型多项目的项目.我需要找到当前用户所有的信用/设备/项目(我认为只有两个列(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

谢谢 !

最好.

堆栈级别到深度指向一个不定式的递归调用,我会说你得到它

has_many :credit, :through => :credit,

这清楚地介绍了某种循环.

翻译自:https://stackoverflow.com/questions/11653117/rails-stack-level-too-deep

转载注明原文:ruby-on-rails – rails:堆栈级别太深