Ruby-on-rails-cheat-sheet-v1

Ruby and Rails Reserved Words

When you develop on Ruby on Rails everyday you get accustomed to creating models, views, controllers, and migrations very quickly. You often do these things without thinking about some of the catches that Ruby and Rails have in them, like reserved words.

While creating a migration, a co-worker asked me if a word was a reserved word. We both didn't know so we started searching the internet. After looking for a while I realized that it was pretty hard to find a comprehensive list of Ruby and Rails reserved words. Because of this I decided to try and put one together that would be useful for developers.

Rails Cheat Sheet

I first came upon a good Rails cheat sheet from Dave at AddedBytes.com. Dave did a really good job of putting this cheat sheet together and it turns out that he has many other developer, and website, cheat sheets that are also very useful. They can be found here.

Rails Cheat Sheet

Rails Reserved Words

Here is a list of documented Ruby on Rails reserved words.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
ADDITIONAL_LOAD_PATHS, ARGF, 
ARGV, ActionController, 
ActionView, ActiveRecord, 
ArgumentError, Array, BasicSocket, 
Benchmark, Bignum, Binding, 
CGI, CGIMethods, CROSS_COMPILING, 
Class, ClassInheritableAttributes, 
Comparable, ConditionVariable, 
Config, Continuation, DRb, 
DRbIdConv, DRbObject, 
DRbUndumped, Data, Date, DateTime, 
Delegater, Delegator, Digest, Dir,
ENV, EOFError, ERB, Enumerable, 
Errno, Exception, FALSE, 
FalseClass, Fcntl, File, 
FileList, FileTask, FileTest, 
FileUtils, Fixnum, Float, 
FloatDomainError, GC, Gem, 
GetoptLong, Hash,
IO, IOError, IPSocket, IPsocket, 
IndexError, Inflector, Integer, 
Interrupt, Kernel,
LN_SUPPORTED, LoadError, 
LocalJumpError, Logger,
Marshal, MatchData, MatchingData, 
Math, Method, Module, Mutex, 
Mysql, MysqlError, MysqlField, 
MysqlRes,
NIL, NameError, NilClass, 
NoMemoryError, 
NoMethodError, NoWrite,
NotImplementedError, Numeric,
OPT_TABLE, Object, ObjectSpace, 
Observable, Observer,
PGError, PGconn, PGlarge, PGresult, 
PLATFORM, PStore, ParseDate,
Precision, Proc, Process,
Queue,
RAKEVERSION, RELEASE_DATE, RUBY, 
RUBY_PLATFORM, RUBY_RELEASE_DATE, 
RUBY_VERSION, Rack, Rake, RakeApp, 
RakeFileUtils, Range, RangeError, 
Rational, 
Regexp, RegexpError, Request, 
RuntimeError,
STDERR, STDIN, STDOUT, ScanError, 
ScriptError, SecurityError, Signal, 
SignalException, SimpleDelegater, 
SimpleDelegator, Singleton, SizedQueue, 
Socket, SocketError, StandardError, 
String, StringScanner, Struct, Symbol, 
SyntaxError, SystemCallError, 
SystemExit, SystemStackError,
TCPServer, TCPSocket, TCPserver, 
TCPsocket, TOPLEVEL_BINDING, 
TRUE, Task, Text, Thread, 
ThreadError, 
ThreadGroup, Time, 
Transaction, TrueClass, 
TypeError, UDPSocket, UDPsocket, 
UNIXServer, UNIXSocket, UNIXserver, 
UNIXsocket, UnboundMethod, Url
VERSION
Verbose
YAML
ZeroDivisionError

Other Rails Reserved Words

Here is a list of undocumented Ruby on Rails reserved words.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
@base_path,
accept, Acces, Axi, action, 
attributes, application2,
callback, category, connection,
database, dispatcher, display1, 
drive,
errors,
format,
host,
key,
layout, load, link,
new, notify,
open,
public,
quote,
render, request, records, 
responses,
save, scope, send, 
session, system,
template, test, timeout, 
to_s, type
URI,
visits,
Observer

Database Field Names

Here is a list of database field names in Rails that are reserved words and used to create fields in the database.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
created_at
created_on
updated_at
updated_on
deleted_at (paranoia gem)
lock_version
type
id
#{table_name}_count
position
parent_id
lft
rgt
quote_value

Ruby Reserved Words

Here is a list of Ruby reserved words that you should be aware of.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
alias, and,
BEGIN, begin, break,
case, class,
def, defined?, do,
else, elsif, END, end, ensure
false, for
if,
module,
next, nil, not,
or,
redo, rescue, retry, return,
self, super,
then, true,
undef, unless, until,
when, while,
yield,
_ _FILE_ _,
_ _LINE_ _