尝试在设计中设置确认 gem

Trying to set up confirmation in devise gem

我在 Windows 机器上使用 Rails 3.2 和 Ruby 4。我正在尝试设置 Devise gem 的确认方面。 gem 工作正常。我从 http://railsapps.github.io/rails-environment-variables.html 了解到,要实际发送确认电子邮件,我需要设置一个电子邮件帐户。因此,我设置了一个临时 Gmail 帐户;在 production.rb 和 test.rb 环境中,我添加了:

  config.action_mailer.smtp_settings = {
    address: "smtp.gmail.com",
    port: 587,
    domain: "example.com",
    authentication: "plain",
    enable_starttls_auto: true,
    user_name: ENV["xxx@gmail.com"],
    password: ENV["xxx"]
  }

我实际上并没有部署该应用程序,而是在本地主机上工作。我已经尝试使用电子邮件地址注册,但没有收到确认邮件。因此,设置完以上设置后,我让app重新发送确认指令。但是,确认电子邮件仍然没有到达(也不在垃圾邮件文件夹中)。

服务器表示如下:

Started POST "/users/confirmation" for 127.0.0.1 at 2015-01-30 19:57:29 +0100
Processing by Devise::ConfirmationsController#create as HTML
  Parameters: {"utf8"=>"V", "authenticity_token"=>"uqVdcfPNDiDw/BGxHQFCxQf9+IZDJs0fOgpHc1hbMDw=", "user"=>{"email"=>"
xxx@gmail.com"}, "commit"=>"Resend confirmation instructions"}
  User Load (1.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`unconfirmed_email` = 'xxx@gmail.com' LIMIT 1
  User Load (1.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`email` = 'xxx@gmail.com' LIMIT 1
  User Load (1.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`confirmation_token` = 'a6f9b9d801276572386b15945ff8
925c7f975c3958f3e2b3dfdd03ff3ba4de88' LIMIT 1
   (0.0ms)  BEGIN
   (1.0ms)  UPDATE `users` SET `confirmation_token` = 'a6f9b9d801276572386b15945ff8925c7f975c3958f3e2b3dfdd03ff3ba4de
88', `confirmation_sent_at` = '2015-01-30 18:57:30', `updated_at` = '2015-01-30 18:57:30' WHERE `users`.`id` = 1
   (54.7ms)  COMMIT
  Rendered devise/mailer/confirmation_instructions.html.erb (2.0ms)

Sent mail to xxx@gmail.com (521ms)
Date: Fri, 30 Jan 2015 19:57:32 +0100
From: xxx@gmail.com
Reply-To: xxx@gmail.com
To: xxx@gmail.com
Message-ID: <54cbd41c501b_11781f9341c148ad@Desktop.mail>
Subject: Confirmation instructions
Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: 7bit

<p>Welcome xxx@gmail.com!</p>

<p>You can confirm your account email through the link below:</p>

<p><a href="http://localhost:3000/users/confirmation?confirmation_token=m6vs52qoWGFX1pM6bqss">Confirm my account</a><
/p>

Redirected to http://localhost:3000/users/sign_in
Completed 302 Found in 3113ms (ActiveRecord: 0.0ms)

非常感谢任何帮助。

我已经开始工作了。错误是 production.rb 和 test.rb:

user_name: ENV["xxx@gmail.com"],
password: ENV["xxx"]

这应该是:

user_name: "xxx@gmail.com",
password: "xxx"