我得到在管理:: ChecklistsController#的“堆栈级别太深” 错误秀#控制器嵌套形式
SystemStackError显示
栈层次过深
的控制器行动:
# GET /admin/checklists/1
# GET /admin/checklists/1.json
def show
@admin_checklist = Admin::Checklist.find(params[:id])
respond_to do |format|
format.html #show.html.erb
format.json { render json: @admin_checklist }
end
end
而模型
class Admin::Checklist < ActiveRecord::Base
attr_accessible :description, :name, :usable, :categories_attributes
has_many :categories, :dependent => :destroy
validates_presence_of :name,:description
accepts_nested_attributes_for :categories, :allow_destroy => true
end
class Admin::Category < ActiveRecord::Base
attr_accessible :export_head, :export_position, :export_text, :frontend_head, :frontend_position, :frontend_text
belongs_to :checklist
validates_presence_of :frontend_head, :frontend_text
end
我已经玩了一下attributes_accessible。如果我更换:categories_attributes通过:类
然后我失去了无限循环的错误,但正如所料,我不能大规模分配任何类别属性了
任何人有一个想法如何,我可以解决这两个错误。
编辑:
发起者联系:: ChecklistsController#秀GET “/管理/清单/ 4” 为192.168.4.191在2012年12月12日10点12分41秒 处理+0100为HTML 参数:{“id”=>“4”} Admin :: Checklist加载(0.2ms)SELECT “admin_checklists”。* FROM“admin_checkli
sts”WHERE“admin_checklists”。“id”=? LIMIT 1 [[“id”,“4”]] CACHE (0.0ms)SELECT“admin_checklists”。* FROM“admin_checklists”WHERE “admi
n_checklists”。“id”=? LIMIT 1 [[ “ID”, “4”]]已完成500内部 服务器在240毫秒SystemStackError(层叠级别太深)错误:ActionPack的(3.2.9) LIB/action_dispatch /中间件/ reloader.rb: 70
渲染 /var/lib/gems/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middlew 是/模板/救援/ _trace.erb(1.5毫秒)渲染 的/ var/lib/gems/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middlew are/templates/rescues/_request_and_response.erb(1.3ms)Rendered /var/lib/gems/1.9.1/gems/ actionpack-3.2.9/lib/action_dispatch/middlew 是在救援/布局(10.7ms)/模板/救援/ diagnostics.erb
我得到这个SQL-Staement大约100次每页请求。这似乎是在活动记录或误使用了一些bug由我嵌套模型活动记录的.....
EDIT2:
IRB(主要):001:0>管理:: Checklist.find('4')Admin :: Checklist加载 (0.2ms)SELECT“admin_checklists”。* FROM“admin_checkli
sts”WHERE“admin_checklists”。“id”=? LIMIT 1 [[“id”,“4”]] =># BrummliBrummliBrummliBrummliBrummliBrummliBr ...”,可用:假的, created_at: “20 11年12月12日13时43分23秒”, 的updated_at: “二零一二年十二月十一日13时43分23秒”>
Ged摆脱了'show.html.erb' [Docs](http://apidock.com/rails/ActionController/MimeResponds/respond_to) – melekes
那不是问题,我知道错了,错误是由find行动。我编辑了最高职位。 – webdev007
试图追查类似的东西,你对这个问题的轨道是什么版本? – wesgarrison