-
-
Save nicedawg/430d678348add4c767c5910fe2f41664 to your computer and use it in GitHub Desktop.
[Beginning Rails 6] Listing 8-16. The create Method in app/controllers/sessions_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SessionsController < ApplicationController | |
def create | |
if user = User.authenticate(params[:email], params[:password]) | |
session[:user_id] = user.id | |
redirect_to root_path, notice: "Logged in successfully" | |
else | |
flash.now[:alert] = "Invalid login/password combination" | |
render :new | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment