Method: ActionDispatch::Routing::Mapper#authenticate
- Defined in:
- lib/devise/rails/routes.rb
#authenticate(scope = nil, block = nil) ⇒ Object
Allow you to add authentication request from the router. Takes an optional scope and block to provide constraints on the model instance itself.
authenticate do
resources :post
end
authenticate(:admin) do
resources :users
end
authenticate :user, lambda {|u| u.role == "admin"} do
root to: "admin/dashboard#show", as: :user_root
end
289 290 291 292 293 |
# File 'lib/devise/rails/routes.rb', line 289 def authenticate(scope = nil, block = nil) constraints_for(:authenticate!, scope, block) do yield end end |