I want to create one user (admin) and I want to use console (without user registration model). I use solution from RailsCasts (http://railscasts.com/episodes/270-authentication-in-rails-3-1).
But I have one problem: when I do User.create(…, :password => “pass”) in console my password stored in database without encription (like “pass”). And I can’t login with my data.
How can I create user from console? 🙂
Straight from the Rails API
You need to include
:password_confirmation => "passin your hash!Right, so taking a look at
has_secure_passwordyou want to performBCrypt::Password.create(unencrypted_password)to obtain it. You’ll need thebcrypt-rubygem to do the above.