I'm trying to setup an email confirmation for my User model for devise. I'm not actually using devise for usernames and passwords and the such, I'm using Facebook authentication for sign-in/registration. However, I need to get and confirm my users' emails after they sign up.
I tried things from many sources so far, but I'm still getting the error: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol
Here's what I did so far:
1 Perform migration to add devise's confirmable relevant columns:
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 Tell the User model that we're using confirmable
class User < ActiveRecord::Base
devise :confirmable
...
#rest of model
...
end
3 Add email to config/initializers/devise.rb
config.mailer_sender = '<my_email_address>@gmail.com'
4 Add mailer info to config/environments/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 Send email in the action:setup in the Users Controller
def setup
user = current_user
user.email = initial_setup_params[:email]
if user.valid?
user.save!
user.send_confirmation_instructions
end
end