Rails设计不会发送确认电子邮件但需要

Gee*_*Out 7 ruby-on-rails devise ruby-on-rails-3

我设置了Devise并且能够创建个人资料.当我创建配置文件并尝试登录时,我收到一条错误消息,表明我尚未确认我的帐户,

我从未收到过我应该确认自己帐户的电子邮件.我选择这样的选项出错了,还是没让Devise给我发电子邮件?

这是我过去的迁移:

class DeviseCreateUsers < ActiveRecord::Migration
  def self.up
    create_table(:users, :options => 'ENGINE=InnoDB DEFAULT CHARSET=utf8') do |t|
      t.database_authenticatable :null => false
      t.recoverable
      t.rememberable
      t.trackable
      t.confirmable
      t.encryptable
      t.column "first_name", :string  
      t.column "last_name", :string
      t.column "organization_name", :string

      t.timestamps
    end

    add_index :users, :email,                :unique => true
  end

  def self.down
    drop_table :users
  end
end
Run Code Online (Sandbox Code Playgroud)

Luc*_*cas 15

开发模式下,您必须将此行添加到config/environments/development.rb

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

然后,检查服务器日志以查看邮件.你应该找到类似的东西:

渲染设计/邮件/确认_instructions.html.erb(19.5ms)

发送邮件至example@mail.com(21951ms)

日期:2011年5月26日星期四12:56:55 +0200

来自:sender@mail.com

回复:sender@mail.com

致:example@mail.com

消息ID:<4dde31f7944bd_5ac277e0e4785c6@L-Portable.mail>

主题:确认说明

哑剧版:1.0

内容类型:text/html;

字符集= UTF-8

Content-Transfer-Encoding: 7bit
<p>Welcome example@mail.com!</p>
<p>You can confirm your account through the link below:</p>
<p><a href="http://localhost:3000/users/confirmation?confirmation_token=Hi0tyRQU8cCFpAbatYFf">Confirm my account</a></p>
Run Code Online (Sandbox Code Playgroud)

你还需要把这一行放进去 config/initializers/devise.rb

config.mailer_sender = "sender@mail.com"
Run Code Online (Sandbox Code Playgroud)

如果你真的没有在日志中这样的邮件,您仍然可以通过利用的价值确认您的账户confirmation_token在你的数据库,并转到此链接

http://localhost:3000/users/confirmation?confirmation_token= #PUT_YOUR_TOKEN_HERE
Run Code Online (Sandbox Code Playgroud)

这应该可以解决问题.

干杯