Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


url_for helper requires "concerns" option #5

gauthier-delacroix opened this Issue · 2 comments

3 participants

Gauthier Delacroix bkimble Todd Siegel
Gauthier Delacroix

Here is something I don't understand :

Here is my route :

      namespace :platforms, path: 'platforms' do
        resource :platform,
          path:              ':platform_name(/:sub_platform_name)',
          platform_name:     name_param_regexp,
          sub_platform_name: name_param_regexp,
          concerns:          [:services, :probes],
          only:              [:show, :edit, :update] do
                resource :nodes

rake routes returns expected routes but here is the strange part :

> app.url_for :controller=>"platforms/nodes", :action=>"index", :platform_name=>"MyPlatform"
ActionController::RoutingError: No route matches {:controller=>"platforms/nodes", :platform_name=>"MyPlatform"}
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:532:in `raise_routing_error'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:528:in `rescue in generate'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:520:in `generate'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:561:in `generate'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:586:in `url_for'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/actionpack-3.2.8/lib/action_dispatch/routing/url_for.rb:148:in `url_for'
        from (irb):10
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
        from /usr/local/rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

but :

> app.url_for :controller=>"platforms/nodes", :action=>"index", :platform_name=>"MyPlatform", concerns: [:services, :probes]
 => ""

Why do I have to add concerns array in my URL parameters ??

Thanks !


Oh nice, I was just coming here to report that url_for wasn't working with concerns period, but I didn't think to explicitly pass the :concerns option. That obviously does not make much sense -- that all of your url helpers need to know the names of the concerns you are using in the routes file.

However, after downloading 4.0.0.beta1 and trying it there, the issue seems to be resolved. There is a disconnect between the url helpers in 3.x and 4.x, I believe, and this gem should not be portrayed as being backwards compatible until the ignoring of :concerns when matching routes issue is implemented. Boo for us guys who want to pick off some of the nicer things in 4.x!

Todd Siegel

I know this it old, but for anyone else that comes along, the following worked for me.

  resource :resource_name do
    concerns :concern_name
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.