4

您如何在设计开发中跳过用户确认。

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

谢谢你的时间!

4

2 回答 2

9

在控制台中创建用户:

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!

或在模型中:

 after_create :skip_conf!

  def skip_conf!
    self.confirm! if Rails.env.development?
  end
于 2014-01-16T17:49:33.260 回答
2

另一种方式:

User.new(email: 'xx@xx.xx', password: '12345678').confirm!

顺便说一句,你可以跳过 :password_confirmation ,因为#confirm!如果记录尚未保留,则跳过验证。

于 2014-04-24T18:13:07.257 回答