diff options
Diffstat (limited to 'actionpack/lib/action_dispatch/routing')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 13 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 |
2 files changed, 12 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 diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c2cacbd288..f3144dc2d3 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -522,6 +522,8 @@ module ActionDispatch define_method(:_generate_paths_by_default) do supports_path end + + private :_generate_paths_by_default end end |