This project is archived and is in readonly mode.

#2025 ✓invalid
kirillrdy

add a check for reserved words in generators

Reported by kirillrdy | February 20th, 2009 @ 12:14 AM | in 2.x

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

Comments and changes to this ticket

  • CancelProfileIsBroken

    CancelProfileIsBroken April 22nd, 2009 @ 10:12 PM

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

  • kirillrdy

    kirillrdy April 22nd, 2009 @ 10:55 PM

    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

  • José Valim

    José Valim August 10th, 2009 @ 11:16 AM

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

  • Evgeniy Dolzhenko

    Evgeniy Dolzhenko August 19th, 2009 @ 01:36 PM

    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?

  • José Valim

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