Method: ActionDispatch::Routing::Mapper#unauthenticated

Defined in:
lib/devise/rails/routes.rb

#unauthenticated(scope = nil) ⇒ Object

Allow you to route based on whether a scope is not authenticated. You can optionally specify which scope.

unauthenticated do
  as :user do
    root to: 'devise/registrations#new'
  end
end

root to: 'dashboard#show'

331
332
333
334
335
336
337
338
339
# File 'lib/devise/rails/routes.rb', line 331

def unauthenticated(scope = nil)
  constraint = lambda do |request|
    not request.env["warden"].authenticate? scope: scope
  end

  constraints(constraint) do
    yield
  end
end