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

Nick Ginanto
  • 31,090
  • 47
  • 134
  • 244
Tim Diggins
  • 4,364
  • 3
  • 30
  • 49

2 Answers2

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

Bill Garrison
  • 2,226
  • 3
  • 34
  • 75
  • 1
    With the caveat that they're not actually "reserved words". – Dave Newton Mar 05 '13 at 14:40
  • 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)) – Tim Diggins Mar 06 '13 at 16:10
0

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

Artur Haddad
  • 1,429
  • 2
  • 16
  • 33
  • 1
    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)". – Tim Diggins Jun 19 '17 at 10:07
  • 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. – Artur Haddad Jun 20 '17 at 04:54