Skip to content

Instantly share code, notes, and snippets.

@eviltrout
Created January 11, 2013 03:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eviltrout/4507631 to your computer and use it in GitHub Desktop.
Save eviltrout/4507631 to your computer and use it in GitHub Desktop.
# 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