Users Resources
Users model
How to generate a user model?
rails generate model User name:string email:string
Two important documents are generated.
db/migrate/[time]_create_users.rb
app/models/user.rb
bundle exec rake db:migrate
How to validate information?
Add password validation.
rails generate migration add_password_digest_to_users password_digest:string
bundle exec rake db:migrate
One important function password_digest
(1) password_digest hash value
(2) password and password_confirmation validation
We need another gem.
gem ‘bcrypt’, ‘3.1.7’
Sign up
First we should change routes.rb:
Then we should change controller:
Then we should change views:
hub.com/benweet/stackedit