From 0c8dd2cab6793973384f7320c2cb2b832ec38aff Mon Sep 17 00:00:00 2001 From: Michael Colavita Date: Mon, 13 Jul 2015 13:48:10 -0400 Subject: :only and :except are now chained for routing resource(s) Allow chaining the :only and :except options for routing resource(s). Previously, the following yielded routes for both show and destroy: resource :account, :only => [:show, :destroy], :except => :destroy This now yields only the show action. This chaining can be useful for passing optional :except options to code that makes use of the :only option (e.g. for a gem with its own routing methods). --- actionpack/lib/action_dispatch/routing/mapper.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 7cfe4693c1..40e00b55c2 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -1061,16 +1061,22 @@ module ActionDispatch end end - def actions + def available_actions if only = @options[:only] Array(only).map(&:to_sym) - elsif except = @options[:except] - default_actions - Array(except).map(&:to_sym) else default_actions end end + def actions + if except = @options[:except] + available_actions - Array(except).map(&:to_sym) + else + available_actions + end + end + def name @as || @name end -- cgit v1.2.3