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.

add a check for reserved words in generators

#2025

It would be very useful and save developers a lot of time, if you check for reserved keywords in generators like scaffold etc.

example ./script/generate scaffold action name:string

Action is Rails reserved keyword, and posting to /actions/create will fail.

list of keywords http://wiki.rubyonrails.org/rail...

Thank you

Reported by kirillrdy · February 20th, 2009 @ 12:14 AM

State: invalid
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. CancelProfileIsBroken
    CancelProfileIsBroken
    • State changed from new to incomplete

    If you're motivated to do this, please send along a patch. But note that in Rails 3.0, the plan is to make the generators able to handle various combinations of ORM/Testing Library/Javascript library (at least), so the issue of figuring out what the reserved words are becomes practically impossible.

    April 22nd, 2009 @ 10:12 PM

  2. kirillrdy
    kirillrdy

    Hi, I am willing to implement it myself.

    I know full protection will be hard to implement, but lets start with something simple, like Model names and properties (database fields)

    I foolishly created(scaffolded) a model with string property "action" on it. It was really hard to find why "update" didn't work. it was posting My model's hash :action => {fields}, and overwrote rail's params[:action].

    Wasn't easy to find.(no helpful error message or anything)

    For first, at least have a blacklist of Model names (eg File) and fields (eg Action).

    I haven't been following rails 3.0 development. But I will try to put some time into this soon.

    Thanks,

    Kirill R

    April 22nd, 2009 @ 10:55 PM

  3. José Valim
    José Valim
    • State changed from incomplete to invalid

    He already check for class collisions in both Rails 2.3 stable and master. For instance, you cannot create a model named File.

    I cannot reproduce the update behavior, because the model action is available at params[:model][:action] and not params[:action]. A couple of keywords are already checked on migrations too.

    August 10th, 2009 @ 11:16 AM

  4. Evgeniy Dolzhenko
    Evgeniy Dolzhenko

    He already check for class collisions in both Rails 2.3 stable and master. For instance, you cannot create a model named File.

    I failed to quickly find the code which does that, could you please find a link?

    August 19th, 2009 @ 01:36 PM

  5. José Valim