最初,我只在我的heroku应用程序上遇到此问题,但在将devise gem更新为2.2.4之后,我在本地主机上也遇到了问题。
我主要担心的是我收到此错误:
ArgumentError (wrong number of arguments (2 for 1)):
app/mailers/user_mailer.rb:58:in `reset_password_instructions'
我已将设计宝石更新为
devise (2.2.4)
我正在跑步:
Rails 3.2.11
我的development.rb初始化程序包含以下主机:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
这是第58行从我的user_mailer.rb文件开始的地方:
def reset_password_instructions(user)
devise_mail(user, :reset_password_instructions)
end
我的问题是,为什么我发送两个论点?它应该只发送我的devise / passwords / new.html.erb文件中定义的电子邮件地址:
<div class="container">
<%= form_for(resource, :html => {:class => "form-signin", :method => :post}, :as => resource_name, :url => password_path(resource_name)) do |f| %>
<h2 class = "form-signin-heading">Forgot your password?</h2>
<%= devise_error_messages! %>
<%= f.email_field :email, :type => "text", :class =>"input-block-level", :placeholder => "Email Address" %>
<%= f.submit "Send me reset password instructions", :class => "btn btn-large btn-primary" %>
</br>
</br>
<%= render "devise/shared/links" %>
<% end %>
</div>
修改 我的reset_password_instructions.html.erb文件位于:
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token =>@resource.reset_password_token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
有人能发现问题吗?
答案 0 :(得分:4)
看起来答案很简单,我不得不遵循设计的升级说明。对于遇到此问题的任何人,可以在Devise 2.2 upgrade instructions
上找到升级到Devise 2.2编辑:
Devise的升级文档包含使用选项块修改方法的说明。要解决此问题,您需要重新定义reset_password_instructions
方法,如下所示(注意,默认情况下使用record
代替user
,但此具体示例使用user
):
def reset_password_instructions(user, opts={})
...
end