diff options
author | José Valim <jose.valim@gmail.com> | 2010-08-24 11:22:51 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-08-24 11:24:31 -0300 |
commit | 542878304dd53bb8bd8962c61dd9404f2ba57ec7 (patch) | |
tree | 83d1de67c51028bc5bce91d1614aec55347f8f67 /actionpack/lib/action_dispatch/routing | |
parent | 20333be581a7fb7584e1689b22b1ed5637c73ffa (diff) | |
download | rails-542878304dd53bb8bd8962c61dd9404f2ba57ec7.tar.gz rails-542878304dd53bb8bd8962c61dd9404f2ba57ec7.tar.bz2 rails-542878304dd53bb8bd8962c61dd9404f2ba57ec7.zip |
Ensure prefix in routes are generated properly.
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 4dc2fc086e..0c77183dc1 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -926,11 +926,11 @@ module ActionDispatch def prefix_name_for_action(action, as) if as.present? - "#{as}_" + as.to_s elsif as - "" + nil elsif !canonical_action?(action, @scope[:scope_level]) - "#{action}_" + action.to_s end end @@ -941,22 +941,19 @@ module ActionDispatch if parent_resource collection_name = parent_resource.collection_name member_name = parent_resource.member_name - name_prefix = "#{name_prefix}_" if name_prefix.present? end - case @scope[:scope_level] + name = case @scope[:scope_level] when :collection - "#{prefix}#{name_prefix}#{collection_name}" + [name_prefix, collection_name] when :new - "#{prefix}new_#{name_prefix}#{member_name}" + [:new, name_prefix, member_name] else - if shallow_scoping? - shallow_prefix = "#{@scope[:shallow_prefix]}_" if @scope[:shallow_prefix].present? - "#{prefix}#{shallow_prefix}#{member_name}" - else - "#{prefix}#{name_prefix}#{member_name}" - end + [shallow_scoping? ? @scope[:shallow_prefix] : name_prefix, member_name] end + + name.unshift(prefix) + name.select(&:present?).join("_") end end |