Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails devise does not send confirmation email but requires

I set up Devise and am able to create a profile. When I create the profiles and try to log in, I get an error message that I have not confirmed my account,

I never got the email which I am supposed to confirm my own account. Did I go wrong in selecting such an option, or not enabling Devise to email me?

Here is the migration I used to make it:

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
like image 555
GeekedOut Avatar asked May 25 '11 23:05

GeekedOut


1 Answers

In development mode, you have to add this line to config/environments/development.rb

config.action_mailer.default_url_options = { :host => 'localhost:3000' }

Then, check your server logs to see the mail. You should find something like that:

Rendered devise/mailer/confirmation_instructions.html.erb (19.5ms)

Sent mail to [email protected] (21951ms)

Date: Thu, 26 May 2011 12:56:55 +0200

From: [email protected]

Reply-To: [email protected]

To: [email protected]

Message-ID: <[email protected]>

Subject: Confirmation instructions

Mime-Version: 1.0

Content-Type: text/html;

charset=UTF-8

Content-Transfer-Encoding: 7bit
<p>Welcome [email protected]!</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>

You also need to put this line in config/initializers/devise.rb

config.mailer_sender = "[email protected]"

If you REALLY don't have this mail in your logs, you can still validate your account by taking the value of confirmation_token in your DB and go to this link

http://localhost:3000/users/confirmation?confirmation_token= #PUT_YOUR_TOKEN_HERE

And that should do the trick.

Cheers

like image 129
Lucas Avatar answered Oct 27 '22 00:10

Lucas