Skip to content

Instantly share code, notes, and snippets.

@thoughtbot
Created August 4, 2009 22:28
Show Gist options
  • Save thoughtbot/162335 to your computer and use it in GitHub Desktop.
Save thoughtbot/162335 to your computer and use it in GitHub Desktop.
class UsersController < Clearance::UsersController
def create
...
sign_in(@user)
end
end
class ParticipationsController < ApplicationController
protected
def ensure_signed_in
unless signed_in?
store_location
flash[:failure] = "Please sign in to participate in this deal."
redirect_to sign_in_path
end
end
end
module NavigationHelper
def authentication_links
if signed_in?
signed_in_links
else
signed_out_links
end
end
def signed_out_links
[link_to("Sign up", sign_up_path),
link_to("Sign in", sign_in_path)]
end
def signed_in_links
[link_to("My Account", edit_user_path(current_user)),
link_to("Sign out", sign_out_path)]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment