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

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

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

谢谢你的时间!

在控制台中创建用户:

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 

其他方式:

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

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