Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Rails-3.0.3 gives Completed 406 Not Acceptable

#6045

Updating to Rails-3.0.3 resulted in 14 tests failing with the message "Completed 406 Not Acceptable in 223ms" returned instead of the expected page. This error indicates that the format of the request cannot be satisfied. Usually a format specification is html or json or pdf. However, the html generated from user_roles_path( user ) in the view template is:


Roles


instead of:


Roles


The question is: Why is Rails 3.0.3 asking for a format of .1 instead of
requesting a user with id == 1? Is this a problem with our template file, a change to Rails, or a bug?

For completeness, the route.rb file has this:

.  .  .
  resource :user do
    resources :roles
  end

  resource :user_session


  resources :users do
    resources  :roles, 
      :controller => 'user_roles'
  end
.  .  .

Reported by James B. Byrne · November 23rd, 2010 @ 02:16 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. James B. Byrne
    James B. Byrne

    Just mouse over the links and you will see the difference in the generated urls.

    November 23rd, 2010 @ 02:18 PM

  2. Andrés Mejía
    Andrés Mejía

    I cannot reproduce this. Can you try to isolate the issue to a minimal application that exhibits the problem? Thanks!

    November 23rd, 2010 @ 11:29 PM

  3. James B. Byrne
    James B. Byrne

    I will try. The difficulty being that we are about to deploy the next release of our application. So, I might be a little while getting to it.

    November 24th, 2010 @ 01:58 AM

  4. James B. Byrne
    James B. Byrne

    I have done a little more investigation and I do not think that I can get things much simpler than this:

    Routes as given above.

    3.0.3 behaviour ( same as 3.0.2 )

    $ rails c
    Using AdapterExtensions
    Loading development environment (Rails 3.0.3)
    ruby-1.8.7-p302 > app.user_roles_path
     => "/user/roles" 
    ruby-1.8.7-p302 > app.user_roles_path( 1 )
     => "/user/roles.1" 
    ruby-1.8.7-p302 > exit
    

    3.0.1 behaviour

    $ rails c
    Using AdapterExtensions
    Loading development environment (Rails 3.0.1)
    ruby-1.8.7-p302 > app.user_roles_path
    ActionController::RoutingError: No route matches {:controller=>"user_roles", :action=>"create"}
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:424:in `raise_routing_error'
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:397:in `generate'
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:453:in `generate'
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:481:in `url_for'
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/url_for.rb:132:in `url_for'
            from /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/actionpack-3.0.1/lib/action_dispatch/routing/route_set.rb:195:in `user_roles_path'
            from (irb):2
    ruby-1.8.7-p302 > app.user_roles_path( 1 )
     => "/users/1/roles"
    

    November 26th, 2010 @ 04:19 PM

  5. James B. Byrne
    James B. Byrne

    I should point out that this behaviour is exhibited after I did the following simplifications:

    1. The entire route.rb file looks like this:
    Proforma::Application.routes.draw do
    
      resource :user do
        resources :roles
      end
    
      resources :users do
        resources  :roles, 
          :controller => 'user_roles'
      end
    
    end
    

    The Gemfile contains only this:

    source 'http://rubygems.org'
    gem "rails", "= 3.0.3"
    gem 'pg
    

    November 26th, 2010 @ 04:37 PM

  6. James B. Byrne
    James B. Byrne

    I generated a new rails-3.0.3 project and added the suspect routes only. The problem is instantly reproducible:

    $ rails c
    Loading development environment (Rails 3.0.3)
    ruby-1.8.7-p302 > 
    ruby-1.8.7-p302 >   app.user_roles_path( 1 )
     => "/user/roles.1"
    

    November 30th, 2010 @ 09:57 PM

  7. José Valim
    José Valim
    • State changed from new to invalid
    • Importance changed from to Low

    A conflict of the routes name is happening here. I don't think this is a regression, but actually a fix as routes methods generated first have higher priority than the ones generated later. If you change the routes order, you should get this fixed. The output of rake routes will also help you.

    December 9th, 2010 @ 07:27 PM

  8. James B. Byrne
    James B. Byrne

    Reordering the resources did resolve the problem.

    December 17th, 2010 @ 10:34 PM