aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-10-30 12:05:13 +0100
committerPiotr Sarnacki <drogus@gmail.com>2013-12-10 21:38:41 +0100
commite6c602da9046a653747ce99c9cab7f08f572fa40 (patch)
tree4c1e831fca000ef772ddbac9f8e26df1c89f1323 /actionpack/lib/action_dispatch
parentb5c5121f67c88a2be1c56e810f5c64013351ce79 (diff)
downloadrails-e6c602da9046a653747ce99c9cab7f08f572fa40.tar.gz
rails-e6c602da9046a653747ce99c9cab7f08f572fa40.tar.bz2
rails-e6c602da9046a653747ce99c9cab7f08f572fa40.zip
Fix mounting engines inside a resources block
When a route is mounted inside a resources block, it's automatically prefixed, so a following code: resources :users do mount Blog::Engine => '/blog' end will generate a user_blog path helper. In order to access engine helpers, we also use "mounted_helpers", a list of helpers associated with each mounted engine, so a path to blog's post can be generated using user_blog.post_path(user, post). The problem I'm fixing here is that mount used a raw :as option, without taking nestings into account. As a result, blog was added to a route set as a `user_blog`, but helper was generated for just `blog`. This commit applies the proper logic for defining a helper for a mounted engine nested in resources or resource block. (closes #8533)
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r--actionpack/lib/action_dispatch/routing/mapper.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb
index 846a6345cb..bfba8d143d 100644
--- a/actionpack/lib/action_dispatch/routing/mapper.rb
+++ b/actionpack/lib/action_dispatch/routing/mapper.rb
@@ -502,11 +502,12 @@ module ActionDispatch
raise "A rack application must be specified" unless path
options[:as] ||= app_name(app)
+ target_as = name_for_action(options[:as], path)
options[:via] ||= :all
match(path, options.merge(:to => app, :anchor => false, :format => false))
- define_generate_prefix(app, options[:as])
+ define_generate_prefix(app, target_as)
self
end