I have devise and omniauth installed for letting users sign up with their facebook account (this works).Now I want to send an email to an user when they have created an account with the facebook login functionality.
I am also using Actionmailer to send trigger based emails to users. Since I am using devise I don't have a create method in my user model to trigger the email, so I thought to make use of the standard functionality of devise to send out a confirmation email. I have added confirmable to the user model, but now i get the following error:
NameError in Devise::RegistrationsController#create undefined local variable or method `confirmed_at' for #
I don't understand the error message. For my perspective the devise gem is quite a black box and I don't see to which controller the error is referring to. Any help from someone who understands the devise gem better than I do?
Thanks in advance!
The reason you are getting that error message is because the blackbox devise confirmation functionality uses fields that it assumes exist on the User model. This means that it assumes you have ensured the columns exist in the database for the users table. You need to do more than just add confirmable to the User model. You also need to add the migration for confirmed_at and then rake db:migrate.
Generate the migration:
rails g migration add_confirmable_to_devise
Make sure the contents of the migration match this:
class AddConfirmableToDevise < ActiveRecord::Migration
def change
change_table(:users) do |t|
t.string :confirmation_token
t.datetime :confirmed_at
t.datetime :confirmation_sent_at
t.string :unconfirmed_email
end
add_index :users, :confirmation_token, :unique => true
end
end
Then run your migration with rake db:migrate.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With