Nice job! Now when you fill in the login form and submit it, the data is sent to the Rails app via a POST request. The request hits the Sessions controller’s
create action. The
create action checks whether your email and password exist in the database, creates a new session, and redirects to the albums page.
Now that users can log in, let’s add the ability to log out.
In the routes file, create a route that maps the URL
/logout to the Sessions controller’s
delete 'logout' => 'sessions#destroy'
In the Session controller, add the
destroy action by setting the session hash to nil and redirecting to the root path
def destroy session[:user_id] = nil redirect_to '/' end