Created
January 11, 2013 03:02
-
-
Save eviltrout/4507631 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
# Keep everything in a database transaction | |
Player.transaction do | |
# Find the player's current goal | |
goal = player.current_goal | |
# Make sure we don't reward goals that have been already been completed | |
unless goal.completed? | |
goal.update_column :completed, true | |
player.score += goal.score | |
player.save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment