Method: ActionDispatch::Routing::Mapper#authenticated
- Defined in:
- lib/devise/rails/routes.rb
#authenticated(scope = nil, block = nil) ⇒ Object
Allow you to route based on whether a scope is authenticated. You can optionally specify which scope and a block. The block accepts a model and allows extra constraints to be done on the instance.
authenticated :admin do
root to: 'admin/dashboard#show', as: :admin_root
end
authenticated do
root to: 'dashboard#show', as: :authenticated_root
end
authenticated :user, lambda {|u| u.role == "admin"} do
root to: "admin/dashboard#show", as: :user_root
end
root to: 'landing#show'
313 314 315 316 317 |
# File 'lib/devise/rails/routes.rb', line 313 def authenticated(scope = nil, block = nil) constraints_for(:authenticate?, scope, block) do yield end end |