Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Devise - Skipping user confirmation in Development

How do you skip user confirmation in development in devise.

I have set up the production environment to send emails with SendGrid, but now I have done that it won't let me log in.

Thanks for your time!

like image 814
JamesJY Avatar asked Dec 20 '22 19:12

JamesJY


2 Answers

create User in console:

user = User.create( 
  :first_name            => 'admin', 
  :last_name             => 'admin', 
  :email                 => '[email protected]', 
  :password              => 'password1', 
  :password_confirmation => 'password1' 
).skip_confirmation! 
 # Devise :doc:
 # If you don't want confirmation to be sent on create, neither a code
 # to be generated, call skip_confirmation!

or in model:

 after_create :skip_conf!

  def skip_conf!
    self.confirm! if Rails.env.development?
  end
like image 131
Philidor Avatar answered Jan 09 '23 14:01

Philidor


Another way:

User.new(email: '[email protected]', password: '12345678').confirm!

BTW, you can skip :password_confirmation at all, because #confirm! skips validation if record does not persisted yet.

like image 20
qd3v Avatar answered Jan 09 '23 14:01

qd3v