Learn

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 :user_id.

Instructions

1.

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

rails console
2.

Retrieve all signed up users in the database by typing

User.all

Your information should show up in the results.

3.

Visit 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.

4.

Exit the Rails console by typing

exit.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?