ruby-on-rails – Rails设计不发送确认电子邮件但需要
我设置了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 解决方法
在开发模式下,您必须将此行添加到config / environments / development.rb
config.action_mailer.default_url_options = {:host => ‘localhost:3000’} 然后,检查服务器日志以查看邮件.你应该找到类似的东西:
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值来验证您的帐户,然后转到此链接 http://localhost:3000/users/confirmation?confirmation_token= #PUT_YOUR_TOKEN_HERE 这应该可以解决问题. 干杯 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |