This project is archived and is in readonly mode.

#5091 ✓resolved
Fabian Schwahn

Creating a model named Format result in code 406

Reported by Fabian Schwahn | July 12th, 2010 @ 10:20 AM

I have created a vanilla Rails3 app and scaffolded a model named Format with one attribute 'name'.
If I send any Post-request to the controller (create or update), it actually performs the Action in the database (i.e. creating or updating the record), but it returns a code 406 to the browser:

Started POST "/formats" for 127.0.0.1 at Mon Jul 12 11:11:03 +0200 2010
  Processing by FormatsController#create as 
  Parameters: {"commit"=>"Create Format", "authenticity_token"=>"ZX5QeLvPrLuypcp0byaBtNGfRQUGX0zuP7/lgP7GwZI="}
  SQL (0.5ms)  INSERT INTO "formats" ("created_at", "name", "updated_at") VALUES ('2010-07-12 09:11:03.710452', 'Test', '2010-07-12 09:11:03.710452')
Completed 406 Not Acceptable in 24ms

I guess this happens because Rails because Rails uses 'format' itself internally and mixes something up. This should either work, or Format should be a reserved word that should not be allowed as a model/controller name.

Version:

ruby 1.8.7 (2010-06-23 patchlevel 299) [i686-darwin10.4.0]
Rails 3.0.0.beta4

Comments and changes to this ticket

  • Fabian Schwahn

    Fabian Schwahn July 12th, 2010 @ 10:33 AM

    Thinking about it a little more, the controller probably mistakes params[:format] as the format of the query, that's why it says

    Processing by FormatsController#create as
    
    without displaying a format at the end. Usually it says something like this:
    Processing by PostsController#create as HTML
    
    Also, the parameters of the Format-model don't show up in the Parameters-hash which is displayed.
    When the controller hits the respond_to-block, it can't find the right format and returns a 406?
  • Ivan Torres (mexpolk)

    Ivan Torres (mexpolk) July 13th, 2010 @ 09:13 PM

    Format is a known Reserved words see Reserved Words You Can’t Use on Rails Wiki.

    Unless the intention is to make it work! ;)

  • Fabian Schwahn

    Fabian Schwahn July 13th, 2010 @ 09:17 PM

    Ah thanks, didn't know that page existed.

  • Mike Riley

    Mike Riley July 29th, 2010 @ 08:53 PM

    • State changed from “new” to “resolved”
    • Importance changed from “” to “Low”

    Hello Fabian,

    Looks like this issue is completed based on Ivan's reply. I am going to close it out. If this is indeed still open let us know so we can reopen it.

    Mike Riley

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>

Pages