How Rails Handles Use of Reserved Keywords, Wow!

I didn’t ever expect to get excited about how a framework handles keywords, but Rails just impressed me big-time. When I tried to create a model named “Activity”, Rails told me it was reserved and then came back with a list of thesaurus terms that might be used instead!. That’s not just opinionated software, it’s downright friendly! Most frameworks don’t bother checking this sort of thing at all, let alone providing helpful “What To Do Now” instructions.

  1. > ruby script/generate model activity
  2.  
  3.   The name 'Activity' is reserved by Ruby on Rails.
  4.   Please choose an alternative and run this generator again.
  5.  
  6.   Suggestions:  
  7.  
  8. Sense 1
  9. activity -- (any specific activity; "they avoided all recreational activity")
  10.       => act, human action, human activity -- (something that people do or cause to happen)
  11.  
  12.  
  13. Sense 2
  14. action, activity, activeness -- (the state of being active; "his sphere of activity"; "he is out of action")
  15.        => state -- (the way something is with respect to its main attributes; "the current state of knowledge"; "his state of health"; "in a weak financial state")
  16.  
  17.  
  18. Sense 3
  19. bodily process, body process, bodily function, activity -- (an organic process that takes place in the body; "respiratory activity")
  20.        => organic process, biological process -- (a process occurring in living organisms)
  21.  
  22.  
  23. Sense 4
  24. activity -- ((chemistry) the capacity of a substance to take part in a chemical reaction; "catalytic activity")
  25.        => capability, capacity -- (the susceptibility of something to a particular treatment; "the capability of a metal to be fused")
  26.  
  27.  
  28. Sense 5
  29. natural process, natural action, action, activity -- (a process existing in or produced by nature (rather than by the intent of human beings); "the action of natural forces"; "volcanic activity")
  30.        => process -- (a sustained phenomenon or one marked by gradual changes through a series of states; "events now in process"; "the process of calcification begins later for boys than for girls")
  31.  
  32.  
  33. Sense 6
  34. activeness, activity -- (the trait of being active; moving or acting rapidly and energetically; "the level of activity declines with age")
  35.        => trait -- (a distinguishing feature of your personal nature)

It’s interesting…the standard HCI advice for showing an error is to not only explain what’s wrong, but how to fix it. “Tell the user what happened, explain the consequences if it’s not obvious, outline how to fix it, explain what to do if they can’t fix it.” Yet, how often do software tools, like compilers, give you anything more than a terse error message. Sure, it’s important to be concise in some cases, but you could always offer an option, like –verbose, to actually provide a few insights.

One thought on “How Rails Handles Use of Reserved Keywords, Wow!

  1. Yet, how often do software tools, like compilers, give you anything more than a terse error message[?]

    Eclipse has been offering ‘Quick Fix’, where the option(s) avaliable to fix the error are presented, and implemented with a couple of mouse clicks, for quite some time.

    If you’re using a compiler directly then what you describe is pretty helpful, but how likely is that in this day and age?

Leave a Reply