设计 - 在开发中删除用户确认

Jam*_*sJY 3 ruby ruby-on-rails devise devise-confirmable ruby-on-rails-4

如何在开发中跳过用户确认.

我已经设置了生产环境以使用SendGrid发送电子邮件,但现在我已经完成了它不会让我登录.

谢谢你的时间!

Зел*_*ный 7

在控制台中创建用户:

user = User.create( 
  :first_name            => 'admin', 
  :last_name             => 'admin', 
  :email                 => 'foo...@email.com', 
  :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!
Run Code Online (Sandbox Code Playgroud)

或在模型中:

 after_create :skip_conf!

  def skip_conf!
    self.confirm! if Rails.env.development?
  end
Run Code Online (Sandbox Code Playgroud)