I've recently picked up ruby and rails and have seen this :foo
syntax in ruby with stuff like attr_accessor, in rails with model methods but I don't quite get it. What's the name of this syntax, what's it do ?
an example of seen cases
class Dog
attr_accessor :name
end
///second scenario
class CreatePurchases < ActiveRecord::Migration
def change
create_table :purchases do |t|
t.string :name
t.float :cost
t.timestamps
end
end
end
//third scenario
class Purchase < ActiveRecord::Base
validates :name, presence: true
validates :cost, numericallity: {greater than : 0}
end