"发送给我重置密码说明"不与Devise合作?

时间:2014-03-18 04:17:04

标签: ruby-on-rails devise

所以我一直在修改Devise视图,当我查看Forgot Password视图,然后点击已注册的电子邮件地址并点击“发送给我重置密码说明”时,我感到非常惊讶。 ,我收到了这个:

enter image description here

这是服务器日志:

Started POST "/users/password" for 127.0.0.1 at 2014-03-18 00:13:14 -0400
Processing by Devise::PasswordsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"uVUzOM4xJcbJSl5uLHgV7vuXnUjw8FsBgLptoedq4cw=", "user"=>{"email"=>"andrew@gmail.com"}, "commit"=>"Send me reset password instructions"}
  User Load (0.3ms)  SELECT "users".* FROM "users" WHERE "users"."email" = 'andrew@gmail.com' ORDER BY "users"."id" ASC LIMIT 1
  User Load (0.1ms)  SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = '96b5adaa30ec048962aa6cbc67c3538af1b0dd36d8aa1a929b9de6ec9b92483b' ORDER BY "users"."id" ASC LIMIT 1
   (0.1ms)  begin transaction
Binary data inserted for `string` type on column `reset_password_token`
  SQL (0.5ms)  UPDATE "users" SET "reset_password_token" = ?, "reset_password_sent_at" = ?, "updated_at" = ? WHERE "users"."id" = 1  [["reset_password_token", "96b5adaa30ec048962aa6cbc67c3538af1b0dd36d8aa1a929b9de6ec9b92483b"], ["reset_password_sent_at", Tue, 18 Mar 2014 04:13:14 UTC +00:00], ["updated_at", Tue, 18 Mar 2014 04:13:14 UTC +00:00]]
   (5.0ms)  commit transaction
  Rendered devise/mailer/reset_password_instructions.html.erb (1.5ms)
Completed 500 Internal Server Error in 57ms

ActionView::Template::Error (Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true):
    2: 
    3: <p>Someone has requested a link to change your password. You can do this through the link below.</p>
    4: 
    5: <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @token) %></p>
    6: 
    7: <p>If you didn't request this, please ignore this email.</p>
    8: <p>Your password won't change until you access the link above and create a new one.</p>
  app/views/devise/mailer/reset_password_instructions.html.erb:5:in `_app_views_devise_mailer_reset_password_instructions_html_erb__2519734817603171421_70315561035180'

我做错了什么,我该如何解决?

2 个答案:

答案 0 :(得分:1)

安装设备后告诉您至少需要复制以下内容

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

config/environments/development.rb

设计需要邮寄程序。

有关详细信息,请参阅https://github.com/plataformatec/devise#getting-started

答案 1 :(得分:-1)

设计需要一些额外的配置才能通过电子邮件重置密码才能正常工作。它除了用于实际发送重置电子邮件的电子邮件帐户和密码外,还需要主持人发送电子邮件。

http://blog.codeschool.com/post/32745236583/re-generating-forgot-password-emails-with-devise有一个关于重置密码电子邮件的好教程。