Hartl Rails Tutorial - Seed User Passwords
I'm going through Michael Hartle's excellent Rails tutorial and I'm trying to wrap my head around the seed users aspect. I just finished chapter 9, so I have a working login / logout / edit / delete system with admin rights. In this chapter, we create some dummy users in the fixture file:
michael:
name: Michael Example
email: michael@example.com
password_digest: <%= User.digest('password') %>
admin: true
My question is, how do I login as michael@example.com ? It is not clear to me what this password is. On a related note, what is the best practice for creating a generic "admin" user? Should I use the instrument or add it to the database via the Rails console before deploying the application?
Thank you for your help!
Edit - here's a link to the BitBucket repository: https://bitbucket.org/jonathan_buck/sample_app/overview
source to share
The password is not stored as-is in the database. Instead, its own assembly / protected version is saved. The #digest method takes a parameter and prints the digest version.
So, technically, the set password is "password". But in the database you will find this nonsense.
Has the meaning?
source to share
To address the basic question, what is a database seed. db / seed.rb is a very nifty thing to help you populate some test users quickly. As you can see, it's a .rb extension, so a regular ruby ββprogram is nothing out of the ordinary. You have access to all of your models and you don't need to enter everything manually from the console. Well, I think the password deal you already figured out forms the previous answers. Just take a look at the digest method and SitePoint is the perfect article on how a user should authenticate. And for your last question check out this article , it will help you understand the concept
source to share