Create a devise user from Ruby console

Create a devise user from Ruby console

Add Comment


  • 3 Answer(s)

    Ruby add false to the save method to skip the validations: 

    User.new({:email => "[email protected]", :roles => ["admin"], :password => "111111", :password_confirmation => "111111" }).save(false)
    

    or

    User.create!({:email => "[email protected]", :roles => ["admin"], :password => "111111", :password_confirmation => "111111" })
    

    Then Confirmable module enabled for devise, make sure you are setting the confirmed_at value to something like Time.now.

    Answered on January 8, 2019.
    Add Comment

    Follow this command: 

    u = User.new(:email => "[email protected]", :password => 'password', :password_confirmation => 'password')
    u.save
    

    And,returns false,

    u.errors
    

    Answered on January 8, 2019.
    Add Comment

    Using :confirmable  object user should be confirm first,

    First is skip confirmation: 

    newuser = User.new({email: '[email protected]', password: 'password', password_confirmation: 'password'})
    newuser.skip_confirmation!
    newuser.save
    

    Use confirm! :

    newuser = User.new({email: '[email protected]', password: 'password', password_confirmation: 'password'})
    newuser.confirm!
    newuser.save
    

    Answered on January 8, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.