Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created March 20, 2010 21:25
Show Gist options
  • Save rbarazi/338919 to your computer and use it in GitHub Desktop.
Save rbarazi/338919 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 7-18. create Method in app/controllers/sessions_controller.rb
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 :action => 'new'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment