繁体   English   中英

Rails devise 不发送确认 email 但需要

[英]Rails devise does not send confirmation email but requires

我设置了 Devise 并能够创建配置文件。 当我创建配置文件并尝试登录时,我收到一条错误消息,提示我尚未确认我的帐户,

我从来没有得到 email 我应该确认我自己的帐户。 我在选择这样一个选项时是否错误地选择了 go,或者没有启用 Devise 到 email 我?

这是我用来进行的迁移:

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

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

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

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

渲染设计/邮件程序/confirmation_instructions.html.erb (19.5ms)

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

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

发件人:发件人@mail.com

回复:sender@mail.com

收件人:example@mail.com

邮件 ID:<4dde31f7944bd_5ac277e0e4785c6@L-Portable.mail>

主题:确认说明

哑剧版:1.0

内容类型:文本/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>

您还需要将此行放在config/initializers/devise.rb

config.mailer_sender = "sender@mail.com"

如果您的日志中确实没有此邮件,您仍然可以通过将您的数据库中的confirmation_token令牌值和go到此链接来验证您的帐户

http://localhost:3000/users/confirmation?confirmation_token= #PUT_YOUR_TOKEN_HERE

这应该可以解决问题。

干杯

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM