Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Routing shortcut missbehaviour in engine #6497

2called-chaos opened this Issue · 5 comments

6 participants


I discovered a bug in the routing within (isolated and mountable) engines.

ProftpdUserManager::Engine.routes.draw do
  # without shortcut
  get 'server/traffic' => "server#traffic"

  # with shortcut
  get 'server/traffic'

  resources :users do
    member do
      get 'enable'
      get 'disable'
      get 'credentials'
      get 'overview_traffic'

  root to: 'users#index'

Without shortcut routes (as excpected) to proftpd_user_manager/server#index
With the shortcut it routes to server#index it misses the namespace there...

Is this a bug or expected?


Sven Pachnit


This is definitely a bug, but it's not specific to engines. All engine does, is wrapping routes with namespace. I will look into this today.

@drogus drogus was assigned

@drogus Can this be closed?

Does wrapping a route with a namespace essentially mean the same thing as having the following config/routes.rb?

# config/routes.rb
FuzzApp::Application.routes.draw do
  namespace :fuzz do
    get 'server/traffic'

With that routes file rake routes has the expected output:

$ rake routes
fuzz_server_traffic GET /fuzz/server/traffic(.:format) fuzz/server#traffic

Also, a routing spec for this claims that it's working.

    { :get => "/fuzz/server/traffic" }.should route_to(:controller => 'fuzz/server', :action => 'traffic')

This is not the issue @kytrinyx the problem is when you are inside a mountable plugin and use the shorthand. By default everything in the engine mountable gets namespaced, but if you use this shorthand, it doesn't.

The problem seems to be this line but I don't know why this check for to_shorthand is there.

Someone with more depth on the routing can probably explain that, else we can remove the || to_shorthand and it should fix this bug.


I removed the || to_shorthand and it fixed the route for me. Ran all the actionpack tests against rails master and they passed. Should I submit a pull request for this?


@Draiken please do, and then we can discuss it there. If you don't want to, let me know and I will.

@Draiken Draiken referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Draiken Draiken referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@rafaelfranca rafaelfranca closed this issue from a commit
@Draiken Draiken Removing to_shorthand from default_controller_and_action. Fixes #6497
When using shortcut routes inside an engine the "to_shorthand" variable
is set to true, causing the module scope of the route to not be applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.