From 2fb0cbec024c5b51451deab7e390e2d4f712cf8f Mon Sep 17 00:00:00 2001 From: Andrew White Date: Tue, 24 Aug 2010 07:27:54 +0100 Subject: When custom resource actions are specified using strings add the default name and action if the string is a valid ruby method name. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#5431 state:resolved] Signed-off-by: José Valim --- actionpack/lib/action_dispatch/routing/mapper.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_dispatch') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 23b13d1d5d..0a6cd63b56 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -736,8 +736,12 @@ module ActionDispatch end elsif resource_method_scope? path = path_for_custom_action - options[:action] ||= action - options[:as] = name_for_action(options[:as]) if options[:as] + if action =~ /^[a-zA-Z][_a-zA-Z0-9]*$/ + options[:action] ||= action + options[:as] = name_for_action(action, options[:as]) + else + options[:as] = name_for_action(options[:as]) if options[:as] + end args.push(options) with_exclusive_scope do -- cgit v1.2.3