Skip to content

Instantly share code, notes, and snippets.

@goodbomb
Last active August 29, 2015 14:05
Show Gist options
  • Save goodbomb/83cb35c99ab853a84cf1 to your computer and use it in GitHub Desktop.
Save goodbomb/83cb35c99ab853a84cf1 to your computer and use it in GitHub Desktop.
# Update Business' supported_causes list and Cause's list of supporters
def update_supporters
@transaction = Transaction.find(self.id)
@type = @transaction.trans_type
@status = @transaction.status
if @type == 'pledge' && @status == 'complete' then
@business_id = @transaction.from_user_id
@cause_id = @transaction.to_user_id
b = User.find(@business_id)
b.supported_causes += Array(@cause_id)
b.save!
c = User.find(@cause_id)
c.supporters += Array(@business_id)
c.save!
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment