Skip to content

Instantly share code, notes, and snippets.

@mrandyclark
Created May 11, 2011 05:57
Show Gist options
  • Save mrandyclark/965991 to your computer and use it in GitHub Desktop.
Save mrandyclark/965991 to your computer and use it in GitHub Desktop.
#model for drinks
belongs_to :person
# this is you, joely!
@joel = Person.where(:first_name => "Joel", :last_name => "Squires").first
# "i'll have a duke please"
Drink.create(:name => "The Duke", :person_id => @joel.id)
# and another
Drink.create(:name => "The Duke", :person_id => @joel.id)
#and another
Drink.create(:name => "The Duke", :person_id => @joel.id)
# im feeling a little woozy, better switch it up
Drink.create(:name => "Miller High Life", :person_id => @joel.id)
# OH HAI AT JOSH FRICKE THANKS FOR SHOT OF PATRON
Drink.create(:name => "Shot of Patron", :person_id => @joel.id)
# i'll have another high life please
Drink.create(:name => "Miller High Life", :person_id => @joel.id)
# oh god, I think I have to puke....
if(@joel.drunk && @joel.puking)
puts "<strong>stupid fuck</strong>"
end
# model for people
has_many :drinks
# if you've had more than 5 drinks, you're drunk
def self.drunk
if(self.drinks.length > 5)
return true
end
return false
end
# if the number of drinks you've had is greater
# than a random number, you're puking
def self.puking
return (self.drinks.length > rand(10))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment