Skip to content

Instantly share code, notes, and snippets.

@adammcarth
Created January 4, 2013 05:28
Show Gist options
  • Save adammcarth/4450178 to your computer and use it in GitHub Desktop.
Save adammcarth/4450178 to your computer and use it in GitHub Desktop.
class UserSession < Authlogic::Session::Base
def remember_me_for
3.months
end
end
class UserSessionsController < ApplicationController
def new
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:success] = "You have been successfully logged in!"
redirect_to profiles_url
else
render :action => "new"
end
end
def destroy
@user_session = UserSession.find
if @user_session.destroy
flash[:notice] = "You have been signed out successfully. Come back soon :)"
redirect_to profiles_url
else
flash[:error] = "Oops, something went wrong! You weren't signed out properly, please try again."
redirect_to profiles_url
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment