Last active
August 29, 2015 14:05
-
-
Save goodbomb/83cb35c99ab853a84cf1 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
# 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