I am using Heroku, Devise & Sendgrid.
These are my settings in environment/production.rb
:
config.action_mailer.default_url_options = { :host => 'myapp.herokuapp.com' }
# ActionMailer Config
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 25,
domain: "myapp.herokuapp.com",
authentication: "plain",
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"]
}
I have set the ENV
variables on Heroku fine, and when I register an account it sends the email correctly to the right email address.
It is just when I click the confirmation link, I get a bunch of errors and it doesn't confirm the account:
Started GET "/users/confirmation?confirmation_token=dZf6Jqc7x88q8tyH5bZp" for XX.XX.XX.XX at 2013-05-20 20:59:29 +0000
2013-05-20T20:59:29.413847+00:00 app[web.1]:
2013-05-20T20:59:29.413847+00:00 app[web.1]: NameError (uninitialized constant Confirmation):
2013-05-20T20:59:29.413847+00:00 app[web.1]:
Edit 1
This is my User.rb
the Devise portion:
class User < ActiveRecord::Base
rolify
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :role_ids, :as => :admin
attr_accessible :name, :email, :password, :password_confirmation, :remember_me
Edit 2
This is what happens in my development.log
when I do the same thing.
Started GET "/users/confirmation?confirmation_token=Gs3UYE2m6D84zfuXfa66" for 127.0.0.1 at 2013-05-20 17:12:39 -0500
Processing by ConfirmationsController#show as HTML
Parameters: {"confirmation_token"=>"Gs3UYE2m6D84zfuXfa66"}
Completed 500 Internal Server Error in 10ms
NameError - uninitialized constant Confirmation:
(gem) activesupport-3.2.13/lib/active_support/dependencies.rb:520:in `load_missing_constant'
I have run all the migrations, maybe I need to generate a new migration for the Confirmable
module? How do I do that?
Edit 3
This is what my users
table within my schema.rb
looks like:
create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "name"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.string "unconfirmed_email"
t.float "sales_today"
t.float "sales_this_week"
t.float "sales_lifetime"
t.boolean "is_seller"
end
So it seems to me that the Confirmable
module is all setup.
Edit 4
I forgot that I actually do override the ConfirmationsController
:
class ConfirmationsController < Devise::ConfirmationsController
load_and_authorize_resource
protected
def after_confirmation_path_for(resource_name, resource)
if resource.has_role? :seller
new_item_path
else
root_path
end
end
end