Skip to content

Instantly share code, notes, and snippets.

@reu
Created September 18, 2011 19:59
Show Gist options
  • Save reu/1225487 to your computer and use it in GitHub Desktop.
Save reu/1225487 to your computer and use it in GitHub Desktop.
Dynamic root_url based on the user being logged or not
root :to => "home#show", :constraints => UserLoggedConstraint.new(false)
root :to => "profile#show", :constraints => UserLoggedConstraint.new(true)
class UserLoggedConstraint
def initialize(logged)
@logged = logged
end
def matches? request
request.session[:user_id].present? == @logged
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment