【问题标题】:devise 3.2.4,"stack level too deep"设计 3.2.4,“堆栈级别太深”
【发布时间】:2014-11-10 15:04:19
【问题描述】:

当我调用找回密码函数时我得到:

错误信息::: PasswordsController#create stack 中的 SystemStackError 级别太深了

html:
    <%= form_for(resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post, :class => 'well form-inline' }) do |f| %>

<span style="font-size:14px;margin-right:10px">email:</span>
<%= f.email_field :email  %>
  <%= f.submit "submit", :class => "btn btn-success", :style => "margin-left:10px" %>
passwords_controller:
def create
self.resource = resource_class.send_reset_password_instructions(params[resource_name])
if successfully_sent?(resource)
  #respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
  respond_to do |format|
    format.html { redirect_to after_sending_reset_password_instructions_path_for(resource_name) }
    format.json { render :json => {:info=>"aaa" }.to_json }
  end
else
  respond_to do |format|
    format.html { redirect_to new_password_path(resource_name),:notice => "bbb" }
    format.json { render :json => {:errors=>"ccc" }.to_json }
  end
end

【问题讨论】:

  • 这通常意味着你正在递归地做某事并且它没有终止。
  • 我发现了问题,在我的 devise.rb 中,我使用了require 'devise_resque_mailer' config.mailer = 'DeviseResqueMailer',然后我删除了它,它可以工作。

标签: ruby-on-rails devise


【解决方案1】:

我也遇到了同样的问题,我的解决方法如下:

=begin
  require 'devise_resque_mailer'
  config.mailer = 'DeviseResqueMailer'
=end

【讨论】:

  • 我已经解决了,方法和你差不多,不过还是谢谢你。
【解决方案2】:

无限循环

作为一项规则,Stack Level Too Deep 通常意味着您的应用程序的一部分具有infinite loop

--

代码

这是devise version

  #app/controllers/devise/passwords_controller.rb
  def create
    self.resource = resource_class.send_reset_password_instructions(resource_params)
    yield resource if block_given?

    if successfully_sent?(resource)
      respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
    else
      respond_with(resource)
    end
  end

查看您的代码,问题可能是您错误地引用了successfully_sent? 方法,您没有关闭您的if,并且您没有使用@987654328 @模式:

def create
   self.resource =    resource_class.send_reset_password_instructions(params[resource_name])
   if successfully_sent?(resource)
       respond_to do |format|
           format.html { redirect_to   after_sending_reset_password_instructions_path_for(resource_name) }
           format.json { render :json => {:info=>"aaa" }.to_json }
       end
   else
       respond_to do |format|
           format.html { redirect_to new_password_path(resource_name) }
           format.json { render :json => {:errors=>"ccc" }.to_json }
       end
   end
end

没有看到控制器的其余部分,我只能建议修复我提出的上述问题

【讨论】:

    猜你喜欢
    • 2011-10-21
    • 2012-03-04
    • 2013-10-05
    • 2011-11-17
    • 2012-07-24
    • 2016-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多