Skip to content

Instantly share code, notes, and snippets.

@quolpr
Last active August 29, 2015 14:25
Show Gist options
  • Save quolpr/9c376fb2dd02864640a9 to your computer and use it in GitHub Desktop.
Save quolpr/9c376fb2dd02864640a9 to your computer and use it in GitHub Desktop.
class MyClass
def initialize(&block)
instance_eval(&block)
end
def say(message)
@message = message
self
end
def to(user)
puts "Hey #{user}, I have a message for you: #{@message}"
end
end
MyClass.new { say('Hello').to('Ryan') }
#bin/rails g model Person name:string age:integer hair_color:integer
class Person < ActiveRecord::Base
validates_presence_of :name
validates :age, numericality: { greater_than: 0 }
enum hair_color: [ :brown, :blond, :black]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment