List of reserved words in rails *3*
Asked Answered
I

2

14

Is there a good, authoritative list of reserved words for RAILS-3?

Candidates:

Background: I'm maintaining a long-serving rails app and it has plenty of usages of reserved words (judging that http://oldwiki.rubyonrails.org/rails/pages/ReservedWords seems to apply to rails2). However, none of these are actually interfering with current activity (the app works... and the specs&features I'm slowly adding to all pass). But as time passes I'd like to remove those usages of reserved words, but don't want to bother if some reserved words are no longer really reserved. So while a longer list might be good for NEW rails apps, I need stronger justification for budget spend than "it has been listed on a webpage at somepoint"...)

Maybe the nature of rails is that you can't find an authoritative list, but you can find "things that didn't work for me at some point"....

Incense answered 3/12, 2012 at 10:33 Comment(0)
O
14

This seems like a pretty comprehensive list. However, you are correct. The very nature of programming means that this list will be ever changing. However I will do some research...maybe there is a site that can list reserved words based on the version of Rails you are using. If not...maybe someone should get working on it :D

Oballa answered 5/3, 2013 at 14:38 Comment(2)
With the caveat that they're not actually "reserved words".Donothingism
Good point - and it's not just rails - 'Range' and 'Group' make life much harder for you as model names ('Range' because of ruby's core Range class, Group because of the SQL term). Still I Bill's idea of a list of problematic words... if you listed WHY the terms are problematic it would give a better logic to when they might be cleared up (e.g.Range might be ok, if you put it within a namespace (haven't tried this), and Group is ok, but you have to do some extra work with escaping the name sometimes (cause ActiveRecord doesn't do this for you always))Incense
S
0

Here's a good collaborative list of reserved words in Rails: https://reservedwords.herokuapp.com/

Stormystorting answered 14/6, 2017 at 20:40 Comment(2)
I think that this is a useful reference point, but it has too much stuff (e.g. ArgumentError -- it would be a big mistake to unknowingly monkey patch* or reuse any existing Ruby class. This is really one TYPE of error. However I also think my original question of "reserved words" is way too broad. I think we are really thinking about "Problematic names for a Rails Model" and "Problematic names for a Rails Model attribute (column)".Incense
I agree There should be something specific for model names. I ended up using this for testing my model names last time, after having trouble with model named "template". Can be a good tool for this kind of consult, but it is too broad.Stormystorting

© 2022 - 2024 — McMap. All rights reserved.