2012-12-11 67 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 %> 

我很抱歉,我不能提供一個答案,爲什麼發生這種情況。