undefined method 'cancel' for Subscription #38

Closed
jwoertink opened this Issue Mar 29, 2012 · 1 comment

2 participants

@jwoertink

If you find a subscription through a customer, then methods like cancel, and reactivate won't exist. This is shown through

Chargify::Customer::Subscritpion.instance_methods(false).include?(:cancel) #=> false
Chargify::Subscription.instance_methods(false).include?(:cancel) #=> true

It looks like there are two different Subscription classes due to the scope.

customer = Chargify::Customer.find_by_reference(some_reference_id)
subscription = chargify_customer.subscriptions.first
puts subscription.class #=> Chargify::Customer::Subscription
real_subscription = Chargify::Subscription.find(subscription.id)
puts real_subscription.class #=> Chargify::Subscription

So calling cancel on subscription would throw an error, but calling cancel on real_subscription would work fine.

@jeremywrowe

This is expected behavior and all actions should be called on the real_ object :) The problem with this gem is that we are using active resource that feels much like active record. This causes a lot of confusion.

This is more of a shout out just so others will know what to do if they stumble on this as well.

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment