This project is archived and is in readonly mode.

#6045 ✓invalid
James B. Byrne

Rails-3.0.3 gives Completed 406 Not Acceptable

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

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
.  .  .

Comments and changes to this ticket

  • James B. Byrne

    James B. Byrne November 23rd, 2010 @ 02:18 PM

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

  • Andrés Mejía

    Andrés Mejía November 23rd, 2010 @ 11:29 PM

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

  • James B. Byrne

    James B. Byrne November 24th, 2010 @ 01:58 AM

    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.

  • James B. Byrne

    James B. Byrne November 26th, 2010 @ 04:19 PM

    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"
    
  • James B. Byrne

    James B. Byrne November 26th, 2010 @ 04:37 PM

    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
    
  • James B. Byrne

    James B. Byrne November 30th, 2010 @ 09:57 PM

    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"
    
  • José Valim

    José Valim December 9th, 2010 @ 07:27 PM

    • 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.

  • James B. Byrne

    James B. Byrne December 17th, 2010 @ 10:34 PM

    Reordering the resources did resolve the problem.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Pages