From d38341b5e0a08e6846ee739413a5a3a8f95cccb8 Mon Sep 17 00:00:00 2001 From: Alexander Uvarov Date: Wed, 10 Aug 2011 15:34:40 +0600 Subject: [PATCH] Don't require explicit scope in authenticate router extension --- lib/devise/rails/routes.rb | 8 ++++++-- test/rails_app/config/routes.rb | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/devise/rails/routes.rb b/lib/devise/rails/routes.rb index 64ed090d..09199de5 100644 --- a/lib/devise/rails/routes.rb +++ b/lib/devise/rails/routes.rb @@ -205,11 +205,15 @@ module ActionDispatch::Routing # Allow you to add authentication request from the router: # - # authenticate(:user) do + # authenticate do # resources :post # end # - def authenticate(scope) + # authenticate(:admin) do + # resources :users + # end + # + def authenticate(scope=nil) constraint = lambda do |request| request.env["warden"].authenticate!(:scope => scope) end diff --git a/test/rails_app/config/routes.rb b/test/rails_app/config/routes.rb index 5b51742b..f696fcba 100644 --- a/test/rails_app/config/routes.rb +++ b/test/rails_app/config/routes.rb @@ -4,7 +4,7 @@ Rails.application.routes.draw do get :expire, :on => :member get :accept, :on => :member - authenticate :user do + authenticate do post :exhibit, :on => :member end end