Created
May 11, 2011 05:57
-
-
Save mrandyclark/965991 to your computer and use it in GitHub Desktop.
This file contains 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
#model for drinks | |
belongs_to :person |
This file contains 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
# 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 |
This file contains 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
# 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