2012-12-11 68 views
2

我得到在管理:: 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秒”>

+0

Ged摆脱了'show.html.erb' [Docs](http://apidock.com/rails/ActionController/MimeResponds/respond_to) – melekes

+0

那不是问题,我知道错了,错误是由find行动。我编辑了最高职位。 – webdev007

+0

试图追查类似的东西,你对这个问题的轨道是什么版本? – wesgarrison

回答

1

滑稽的事实,现在它工作我不太确定是什么修复了它,因为我什么也没有改变,我刚从我的休息时间回来,在控制台上找到了它,再次检查了它,并得到了一个属于格式不正确的循环的错误信息,因为我已经再次删除它,这是我的固定粘贴在再次去除部。

<p id="notice"><%= notice %></p> 

<p> 
    <b>Name:</b> 
    <%= @admin_checklist.name %> 
</p> 

<p> 
    <b>Description:</b> 
    <%= @admin_checklist.description %> 
</p> 

<p> 
    <b>Usable:</b> 
    <%= @admin_checklist.usable %> 
</p> 

<p> 
    <ul> 
     <% @admin_checklist.categories.each do |category|%> 
      <li> 
       <h3><%= category.frontend_head %></h3> 
       <p><%= category.frontend_text %></p> 
      </li> 
     <% end %> 
    </ul> 
</p> 


<%= link_to 'Edit', edit_admin_checklist_path(@admin_checklist) %> | 
<%= link_to 'Back', admin_checklists_path %> 

我很抱歉,我不能提供一个答案,为什么发生这种情况。