In this project, we'll practice using the Devise gem to add authentication and authorization.
Our goal is to allow users to bookmark movies that they intend to watch or that they loved. In other words, we need to be able to identify users and tailor the application for them, rather than having the app treat all visitors the same.
Our starting point is the target for the last project, MSM Associations. Now we want to add the following:
- Make the "Dummy" sign in, edit profile, etc, links actually work; users should be able to register with their email and password. How can we achieve this?
- Then, users should be able to click a button on a movie's show page to bookmark it.
- Users should be able to visit a page that shows a list of movies that they have bookmarked.
Note: Windows users, at some point you may run into an error with the bcrypt gem when you try to rails db:seed or sign in with the admin user. In order to resolve,
-
Shut down your
rails server
if you have one running, and/or -
Launch Command Prompt with Ruby on Rails, and navigate to your project folder.
-
At the command line, run:
gem uninstall bcrypt
If you're asked "Continue with Uninstall?", answer "y".
-
At the command line, run:
gem uninstall bcrypt-ruby
If you're asked "Continue with Uninstall?", answer "y".
-
At the command line, run:
gem install bcrypt --platform=ruby
If you're asked "Continue with Uninstall?", answer "y".
-
In Atom, add the following to the
/Gemfile
:gem 'bcrypt', platforms: :ruby
-
At the command line, run:
bundle install
-
(Re)start your
rails server
, and you should be good to go!
-
Fork, clone, and open the code.
-
bundle install
-
Start the server and navigate to http://localhost:3000
-
Quickly pre-populate some data:
rake db:seed:characters
Have the Devise Guide open in a tab to refer to as we work together.