Created
October 27, 2010 15:48
-
-
Save gisikw/649305 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateMedications < ActiveRecord::Migration | |
def self.up | |
create_table :medications do |t| | |
t.string :name | |
t.string :prescriber | |
t.date :dispense_date | |
t.integer :quantity | |
t.integer :days_supply | |
t.boolean :imported, :default => false | |
t.boolean :stopped, :default => false | |
t.timestamps | |
end | |
end | |
def self.down | |
drop_table :medications | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Medication < ActiveRecord::Base | |
end | |
@medication = Medication.first | |
@medication.name = "Prozac" | |
@medication.save | |
@medication.potency | |
# --> NoMethodError: undefined method `potency' for #<Medication:0x103926db0> | |
@medication = Medication.find_by_name("Prozac") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
["hello","goodbye","howdy"].each do |word| | |
eval <<-END | |
def say_#{word} | |
puts "#{word}" | |
end | |
END | |
end | |
end | |
f = Foo.new | |
f.say_hello | |
# --> Hello |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
def method_missing(method_name) | |
if method_name.to_s =~ /^say_([a-z]+)$/ | |
puts $1 | |
else | |
super | |
end | |
end | |
end | |
f = Foo.new | |
f.say_bonjour | |
# --> bonjour |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum = 1 + 1 | |
sum.class # => Fixnum | |
array = [1,2,3] | |
array << 4 | |
array = 5 | |
symbol = :foo | |
hash = {:arg1 => "val1", :arg2 => "val2"} | |
hash[:arg3] = "val3" | |
@instance_variable = "string" | |
def my_method(arg1) | |
puts arg1 | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'sinatra' | |
get '/' do | |
"Welcome to the index page" | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
html | |
background: #ccc | |
body | |
width: 960px | |
margin: 0 auto | |
background: #fff | |
h1, h2 | |
font-size: 18px | |
p | |
a | |
color: red | |
&:hover | |
color: purple |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment