This is a new syntax in Ruby 1.9 for defining symbols that are the keys in a hash.
Both prepended and appended :
's define a symbol
, but the latter is only valid during the initialization of a hash.
You can think of a symbol as a lightweight string constant.
It is equivalent to
:dependent => :destroy
Prior to 1.9, hashes were defined with a syntax that is slightly more verbose and awkward to type:
hash = {
:key => "value",
:another_key => 4
}
They simplified it in 1.9:
hash = {
key: "value",
another_key: 4
}
If you are ever writing a module you want to use on Ruby prior to 1.9, make sure you use the older syntax.