【问题标题】:Wrong number of arguments (given 0, expected 1+) Rails错误数量的参数(给定 0,预期 1+)Rails
【发布时间】:2017-03-14 17:47:02
【问题描述】:

我在几乎没有自定义的devise 新密码页面上收到此错误:

wrong number of arguments (given 0, expected 1+)

我的 ERB 相当简单:

<h1 style="color: black">Forgot Your Password?</h1>

<%= simple_form_for(resource, as: resource_name, url: password_path, html: { method: :post }) do |f| %>  <<<<<<<ERROR CALLED ON THIS LINE
    <%= f.error_notification %>

    <div class="form-inputs text-left">
        <%= f.input :email, required: true, autofocus: true %>
    </div>

    <div class="form-actions">
        <%= f.button :submit, "Send Me Reset Password Instructions", class: "btn-custom" %>
    </div>
<% end %>

<%= render "devise/shared/links" %>

但我似乎无法弄清楚为什么会产生此错误。有没有人遇到过这个问题?

【问题讨论】:

  • 您是否尝试过在该行上运行调试,也许使用 Pry?
  • @iain,我不太确定在这种情况下如何做到这一点......
  • 这可能会有所帮助,在 Rails 中有一个很好的调试部分。设置您的绑定,然后 next next next 直到您到达它失败的点,您可以开始解决问题。 sitepoint.com/pry-friends-rails

标签: ruby-on-rails devise


【解决方案1】:

您需要将password_path 更改为password_path(resource_name)

【讨论】:

  • 完美!谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-08-02
  • 2021-12-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多