Skip to content

Instantly share code, notes, and snippets.

@buethling
Created March 2, 2011 17:25
Show Gist options
  • Save buethling/851321 to your computer and use it in GitHub Desktop.
Save buethling/851321 to your computer and use it in GitHub Desktop.
rails session controller
class SessionsController < ApplicationController
def new
@title = "Sign in"
end
def create
user = User.authenticate(params[:session][:email],
params[:session][:password])
if user.nil?
flash.now[:error] = "Invalid email/password combination."
@title = "Sign in"
render 'new'
else
sign_in user
redirect_to user
end
end
def destroy
sign_out
redirect_to root_path
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment