Skip to content

Instantly share code, notes, and snippets.

@jkongie
Created May 12, 2012 07:05
Show Gist options
  • Save jkongie/2664796 to your computer and use it in GitHub Desktop.
Save jkongie/2664796 to your computer and use it in GitHub Desktop.
Homepage routing based on authenticated status.
Reference links
http://robots.thoughtbot.com/post/22605580334/constrain-yourself
https://github.com/hassox/warden/wiki/overview
# config/routes.rb
root to: 'projects#index', constraints: Devise::SignedInConstraint
devise_scope :user do
root to: 'devise/sessions#new'
end
# 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