I'm working my way through the excellent Rails tutorial by Michael Hartl, and I'm trying to wrap my head around an aspect of the seed users. I just finished chapter 9, so I've got a working login/logout/edit/delete system with admin privileges. As part of this chapter, we create some dummy users in the fixtures file:
michael:
name: Michael Example
email: [email protected]
password_digest: <%= User.digest('password') %>
admin: true
My question is: how do I login as [email protected]? It's not clear to me what the password is. On a related note, what is the best practice for creating a universal "admin" user? Should I use a fixture, or should I add one to the database through the Rails console before deploying the app?
Thanks for your help!
Edit - here's the link to the BitBucket repository: https://bitbucket.org/jonathan_buck/sample_app/overview
You're generating password digest from string "password"
User.digest('password')
So user's password is "password"
The password is not saved as-is in the database. Instead a digest/secured version of the same is saved. The method #digest takes a parameter and outputs the digest version.
So, technically, the set password is "password". But in the database, you'll find it gibberish.
Makes sense?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With