@ page.title:SystemStackError(堆栈级别太深)

时间:2013-01-20 11:17:43

标签: ruby-on-rails

我在创建新网页时遇到问题。

页面模型:

1.9.2-p180 :002>页

 => Page(id: integer, meta_keywords: text, meta_description: text, title: string, header: string, url: string, teaser: text, content: text, publicated_at: date, created_at: datetime, updated_at: datetime, parent_id: integer, lft: integer, rgt: integer)

得到这个按摩: 的> Page.new

SystemStackError: stack level too deep
    from /home/raz/.rvm/gems/ruby-1.9.2-p180@travel/gems/globalize3- .3.0/lib/globalize.rb:60

在rails控制台中。

PRY 中我得到了这个:

[3] pry(main)> @page=Page.new
=> #<Page:0x5c86630>
[4] pry(main)> @page.id
=> nil
[5] pry(main)> @page.title
SystemStackError: stack level too deep
from /home/raz/.rvm/gems/ruby-1.9.2-p180@travel/gems/pry-0.9.11.3/lib/pry/pry_instance.rb:327
[6] pry(main)> @page.content
SystemStackError: stack level too deep
from /home/raz/.rvm/gems/ruby-1.9.2-p180@travel/gems/pry-0.9.11.3/lib/pry/pry_instance.rb:327

Page.rb:

class Page < ActiveRecord::Base
  translates :meta_keywords, :meta_description, :title, :header, :teaser, :content
  acts_as_nested_set

  has_one :gallery
  has_one :hotel_numbers_data
  has_one :tour_prices_data
  ... differnt def...
end  

pages_controller 中的新方法:

def new
@page = Page.new
if params[:parent_id]      
  @page.parent_id = params[:parent_id]
  binding.pry     
end
respond_to do |format|
  binding.pry
  format.html { render :layout => "admin" }
  format.xml  { render :xml => @page }
end
end

1 个答案:

答案 0 :(得分:0)

我只需要实现翻译表或评论跟随行: 翻译:meta_keywords,:meta_description,:title,:header,:teaser,:content 在页面模型