From fbfb9779a90d18f59954be7fb26dd463468ff278 Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Thu, 14 Jan 2016 12:59:05 -0700 Subject: [PATCH] Good stuff. Just added some notes about Ruby conventions. This is pretty good man! --- app/controllers/donations_controller.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/controllers/donations_controller.rb b/app/controllers/donations_controller.rb index 5445a24..ad3b4cd 100644 --- a/app/controllers/donations_controller.rb +++ b/app/controllers/donations_controller.rb @@ -15,6 +15,9 @@ def new def create @donation = @recipient.donations.build(donation_params) @stripe_token = :stripe_token + # When evaluating booleans, you don't need `== true`. `if @donation.recurring` + # is all you need. Additionally, ruby's convention is to call the property + # `is_recurring`, but that's probably a bigger refactor. if @donation.recurring == true if @donation.subscribe_stripe_customer && @donation.save DonationMailer.monthly_donation_receipt(@donation).deliver_later @@ -52,6 +55,7 @@ def edit def update @donation = @recipient.donations.find(params[:id]) if @donation.update(donation_params) + # The ruby convention is to use `unless` when evaluating a false boolean. So `unless @donation.recurring`. if @donation.recurring == false @donation.delete_stripe_customer DonationMailer.cancel_monthly_donation_confirmation(@donation).deliver_later