diff options
author | Santiago Pastorino <santiago@wyeworks.com> | 2014-12-06 13:06:41 -0200 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2014-12-06 13:06:41 -0200 |
commit | 01c3b92ac3e75eb5165e87e6b0ec05b5d8b73fa9 (patch) | |
tree | 99456357ed3cd9da7b20608870360602f6b148df /actionpack/lib/action_dispatch/routing/mapper.rb | |
parent | f9b2ad719a05afa2ef9d45e77bcb7a98906b2088 (diff) | |
parent | ee65f48c2666a660cc48496c8bc9f63113a41e44 (diff) | |
download | rails-01c3b92ac3e75eb5165e87e6b0ec05b5d8b73fa9.tar.gz rails-01c3b92ac3e75eb5165e87e6b0ec05b5d8b73fa9.tar.bz2 rails-01c3b92ac3e75eb5165e87e6b0ec05b5d8b73fa9.zip |
Merge pull request #17944 from tjschuck/mounted_named_routes_regression
Mounted Rack apps should have default named routes based on app name
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 5040aa82b2..f07a4aa674 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -579,15 +579,14 @@ module ActionDispatch raise "A rack application must be specified" unless path - rails_app = rails_app? app - options[:as] ||= app.railtie_name if rails_app + 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, target_as) if rails_app + define_generate_prefix(app, target_as) if rails_app?(app) self end @@ -612,6 +611,14 @@ module ActionDispatch app.is_a?(Class) && app < Rails::Railtie end + def app_name(app) + if rails_app?(app) + app.railtie_name + elsif class_name = app.try(:name) + ActiveSupport::Inflector.underscore(class_name).tr("/", "_") + end + end + def define_generate_prefix(app, name) _route = @set.named_routes.get name _routes = @set |