Created
January 4, 2013 05:28
-
-
Save adammcarth/4450178 to your computer and use it in GitHub Desktop.
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 UserSession < Authlogic::Session::Base | |
def remember_me_for | |
3.months | |
end | |
end |
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 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