Skip to content

Instantly share code, notes, and snippets.

@alexclarkofficial
Created October 11, 2013 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexclarkofficial/6928128 to your computer and use it in GitHub Desktop.
Save alexclarkofficial/6928128 to your computer and use it in GitHub Desktop.
Controller
class SessionsController < ApplicationController
def new
end
def create
user = User.find_by(name: params[:session][:name].downcase)
if user && user.authenticate(params[:session][:password])
sign_in user
redirect_to user
else
flash[:error] = 'Please enter a valid username or email' # Not quite right!
redirect_to root_path
end
end
def destroy
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment