[英]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.