Ruby on rails 设计忘记密码不工作
我正在rails 3上使用Desive进行身份验证。登录、注销、注册工作正常,但在忘记密码的情况下不会发生任何事情。当我点击忘记密码链接时,我会进入Ruby on rails 设计忘记密码不工作,ruby-on-rails,ruby-on-rails-3,authentication,devise,Ruby On Rails,Ruby On Rails 3,Authentication,Devise,我正在rails 3上使用Desive进行身份验证。登录、注销、注册工作正常,但在忘记密码的情况下不会发生任何事情。当我点击忘记密码链接时,我会进入http://localhost:3000/users/password/new链接后,我会收到一张表格,询问我的电子邮件地址和一个send me reset password instructions按钮,但当我点击这个按钮时,我会进入http://localhost:3000/users/sign_in但我没有收到关于重置密码的邮件 在控制台上,
http://localhost:3000/users/password/new
链接后,我会收到一张表格,询问我的电子邮件地址和一个send me reset password instructions按钮,但当我点击这个按钮时,我会进入http://localhost:3000/users/sign_in
但我没有收到关于重置密码的邮件
在控制台上,我可以看到以下内容:
Sent mail to nikitasalunkhe.3@gmail.com (968ms)
Date: Tue, 05 Jun 2012 13:14:22 +0530
From: please-change-me-at-config-initializers-devise@example.com
Reply-To: please-change-me-at-config-initializers-devise@example.com
To: nikitasalunkhe.3@gmail.com
Message-ID: <4fcdb8d6de776_dd624e71f0a78a7@user-G41MT-S2.mail>
Subject: Reset password instructions
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
<p>Hello nikitasalunkhe.3@gmail.com!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><a href="http://localhost:3000/users/password/edit?reset_password_token=gUB8L9nWNikjVJpnhbDW">Change my password</a></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>
这是development.rb文件代码:
Alumnicell::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
end
我应该做哪些更改才能使其正常工作?是否安装了本地邮件程序守护程序?我的最佳解决方案是像这样使用gmail smtp(使用您的设置): 在config/environments/development.rb中:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'mondomaine.com',
:user_name => 'smtp@mondomaine.com',
:password => 'mypassword',
:authentication => 'plain',
:enable_starttls_auto => true }
并删除您的行:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
在生产模式下,您将有一个本地邮件服务器作为后缀。解决了这个问题…在my development.rb文件中做了如下更改:
require 'tlsmail'
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.gmail.com",
:port => 587,
:tls => true,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => "nikitasalunkhe.3@gmail.com",
:password => "seceret_password"
}
代替localhost:3000,试着给你的gmail帐户名。解决这个问题的另一种方法是创建一个文件 “config/initializer/setup\u mail.rb”
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "googlemail.com",
:user_name => "ayushcshah@gmail.com",
:password => "secret_password",
:authentication => "plain",
:enable_starttls_auto => true
}
是的,我查过了,但也没有邮件。我上面的解决方案对你有好处吗?最好的方法是使用邮件服务器。你可以在本地安装一个(非常无聊…)或者使用one.sry bt no luck…我在designe/passwords控制器中得到了新的错误nomethoder错误#为nil创建未定义的方法'ago':nilclass尝试在初始化器designe上检查/添加config.reset_password_=1.hour内。未注释nomethoder错误上面的那一行现在不见了,但我仍然看不到inboxI中的任何邮件我强烈建议sendgrid,也。还建议将其添加到应用程序yaml中:
config.action_mailer.default_url_options = { :host => 'my@gmail.com' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "googlemail.com",
:user_name => "ayushcshah@gmail.com",
:password => "secret_password",
:authentication => "plain",
:enable_starttls_auto => true
}