Hi!
I feel stupid for having to ask this, but I have never run into this
before…
I have this code that should send an email when someone upgrades their
account. I am using this code:
new_plan = Plan.find(params[:customer][:plan_id])
previous_plan = @customer.plan
@customer.change_plan(new_plan)
@customer.save!
ElectronicMailer.deliver_notify_upgrade(@customer.name,
@customer.url, @customer.plan.name, previous_plan.name,
@customer.billing_id, @customer.start_date) # if new_plan.price >
previous_plan.price
The problem is an email never gets send, because new_plan.price is
always equal to previous_plan.price, so it apparently previous_plan
holds a reference to the customer’s plan and when I change that,
previous_plan changes too.
When I change: previous_plan = @customer.plan
to: previous_plan = Plan.find(@customer.plan_id)
it does work, but it feels like I don’t need the extra find…
How would you guys do this?
Thanks,
Mischa.