When the colon is before the variable / object, it denotes a “symbol”, meaning a piece of data to be placed there. The symbol can typically be used in the likes of calling an attribute (key) or in part of a hash: @user.comment[:created_at]
When the colon is after the variable / object, it means you’re setting or getting some sort of value in a key: value
pair. {key: value}
pairs are used mostly in hashes, kind of like an array except you can call the specific keys. This is how the attributes of models are invoked in Rails. EG:
@user = {name: "joe", email: "[email protected]"}
@user.name #-> "joe"
3
solved Ruby on Rails variables, object attributes, and methods that use a : before or after them