Nice job! Now when you fill in the signup form and submit it, the data is sent to the Rails app via a POST request. The request hits the User controller’s
create action. The
create action saves the data, creates a new session, and redirects to the albums page.
How is a new session created? Sessions are stored as key/value pairs. In the
create action, the line
session[:user_id] = @user.id
creates a new session by taking the value
@user.id and assigning it to the key
Let’s check whether the data saved to the database using the Rails console. The Rails console is a useful tool to interact with Rails apps. We’ll use it here to query the database.
Start the Rails console by running
Retrieve all signed up users in the database by typing
Your information should show up in the results.
http://localhost:8000/signup to sign up a few more users through the signup form.
After signing up new users, you can use the Rails console to retrieve all signed up users once more with
User.all. You should see a list of all the users you’ve signed up both through the browser and the Rails console.
Exit the Rails console by typing