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.

Throw a warning at generate scaffold and rake:db migration if fieldnames match rail's reserved words.

#5824

Today I spend some hours figuring out why my enumeration to the field "type" did not save. Without validation the record would save and would silently ignore my type field. I thought I made an mistake on the dozens of setups you can have for enumerations / static array options.

Being a newbie: in the end I tried to do it via the Console, ran "r s" created a new object, setting some fields including objname.type = 'something' and save it. That worked... which I did not expect. Though on entering my scaffold index view it told:

"The single-table inheritance mechanism failed to locate the subclass: 'foo'. This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Component.inheritance_column to use another column for that information."

So I looked for reserved words and found this: http://juicebar.wordpress.com/2007/05/30/reserved-words-in-rails/

Reported by cake_joe · October 16th, 2010 @ 04:32 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. cake_joe
    cake_joe

    My suggestion is:
    Throw a warning at generate scaffold and rake:db migration if fieldnames match rail's reserved words.

    Caveat: I am not so sure about migrations because they could work without ActiveRecord, and I do not know if the reserved words are specific to AR or ActiveModel.

    October 16th, 2010 @ 04:34 PM

  2. cake_joe
    cake_joe
    • Tag changed from reserved words, enumeration, pola, scaffold, type, warnings to reserved words, enumeration, pola, rails3, scaffold, type, warnings

    October 16th, 2010 @ 04:40 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:28 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:28 PM

  5. bingbing