简体   繁体   English

rails:堆栈级别太深

[英]rails : stack level too deep

Actually i'm on a project for a model many->many. 实际上我正在进行一个多模型的项目 - >很多。 I need to find with a current user all credits/devices/project (and I think it's useless to have a table credit with only two column (id & score) so I merge this table to the join table). 我需要找到当前用户所有的信用/设备/项目(我认为只有两个列(id和score)的表信用是没用的,所以我将这个表合并到连接表中)。

I get this error : 我收到此错误:

SystemStackError in Users#show

Showing app/views/shared/_credit.html.erb where line # raised:

stack level too deep

And the two model : 而这两个模型:

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

Thank ! 谢谢 !

Best. 最好。

Stack level to deep points to an infinitive recursive call, and I would say you get that with 堆栈级别到深度指向一个不定式的递归调用,我会说你得到它

has_many :credit, :through => :credit,

which clearly introduces a cycle of some sort. 这显然引入了某种循环。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM