Created
May 12, 2009 03:44
-
-
Save wallace/110295 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
| def save | |
| self.is_account_owner = true # we need to make sure that this user is an account owner | |
| self.authority = "superadmin" # we need to make sure that this user is a super | |
| - return unless self.valid? | |
| - Account.transaction do | |
| - account.save | |
| - account.users << user | |
| - account_credit_card.account_id = account.id | |
| - account_credit_card.save | |
| + return if not self.valid? | |
| + begin | |
| + Account.transaction do | |
| + account.save! | |
| + user.account = account | |
| + user.save! | |
| + account_credit_card.account_id = account.id | |
| + account_credit_card.save! | |
| + end | |
| + rescue | |
| + false | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment