2016-07-27 26 views
0

我想爲我的用戶模型的設計安裝電子郵件確認。我實際上並沒有使用用戶名和密碼等設備,我使用Facebook身份驗證進行登錄/註冊。但是,我需要在註冊後獲取並確認用戶的電子郵件。Rails設計確認電子郵件錯誤:SSL_connect返回= 1 errno = 0狀態= SSLv2/v3讀取服務器你好 - 答:未知的協議

我試圖從許多來源的事情,到目前爲止,但我仍然得到錯誤:所以SSL_connect返回= 1個錯誤號= 0狀態=的SSLv2/v3的讀取服務器問候答:未知協議

這裏就是我這樣做遠:

1執行遷移加色器件的可確定的相關列:

class AddConfirmableToDevise < ActiveRecord::Migration 
    def change 
     add_column :users, :email, :string 
     add_column :users, :confirmation_token, :string 
     add_column :users, :confirmed_at, :datetime 
     add_column :users, :confirmation_sent_at, :datetime 
    end 
end 

2告訴用戶模型,我們使用的是可確定

class User < ActiveRecord::Base 
    devise :confirmable 
    ... 
    #rest of model 
    ... 
end 

3 EMAIL新增配置/初始化/ devise.rb

config.mailer_sender = '<my_email_address>@gmail.com' 

4添加郵件信息到config /環境/ development.rb

config.action_mailer.delivery_method = :smtp 
config.action_mailer.smtp_settings = { 
    address:    'smtp.gmail.com', 
    port:     587, 
    domain:    'localhost:3000', 
    user_name:   '<gmail_username>', 
    password:    '<gmail_password>', 
    authentication:  'plain', 
    enable_starttls_auto: true } 

5發送的電子郵件的行動:設置在用戶控制器

def setup 
    user = current_user 
    user.email = initial_setup_params[:email] 
    if user.valid? 
     user.save! 
     user.send_confirmation_instructions 
    end 
end 

回答

0

我實際上找到了這個問題的答案中途通過,但我想我會張貼反正我在f並且在任何其他人都有同樣的錯誤的機會。顯然,我已經將第4步的代碼粘貼到了config/environment.rb文件中。 Idk,如果我誤解了一個教程或什麼,但我刪除了它,現在它工作。

相關問題