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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Creating a model named Format result in code 406

#5091

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

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

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

Activity

  1. Fabian Schwahn
    Fabian Schwahn

    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?

    July 12th, 2010 @ 10:33 AM

  2. Ivan Torres (mexpolk)
    Ivan Torres (mexpolk)

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

    Unless the intention is to make it work! ;)

    July 13th, 2010 @ 09:13 PM

  3. Fabian Schwahn
    Fabian Schwahn

    Ah thanks, didn't know that page existed.

    July 13th, 2010 @ 09:17 PM

  4. Mike Riley
    Mike Riley
    • 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

    July 29th, 2010 @ 08:53 PM