Skip to content

Instantly share code, notes, and snippets.

@wallace
Created May 12, 2009 03:44
Show Gist options
  • Select an option

  • Save wallace/110295 to your computer and use it in GitHub Desktop.

Select an option

Save wallace/110295 to your computer and use it in GitHub Desktop.
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