Created
May 12, 2012 07:05
-
-
Save jkongie/2664796 to your computer and use it in GitHub Desktop.
Homepage routing based on authenticated status.
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
Reference links | |
http://robots.thoughtbot.com/post/22605580334/constrain-yourself | |
https://github.com/hassox/warden/wiki/overview |
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
# config/routes.rb | |
root to: 'projects#index', constraints: Devise::SignedInConstraint | |
devise_scope :user do | |
root to: 'devise/sessions#new' | |
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
# lib/devise/signed_in_constraint.rb | |
module Devise | |
class SignedInConstraint | |
def self.matches?(request) | |
request.env['warden'].authenticated? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment