mercredi 31 août 2016

Koudoku: NoMethodError on User Model

Posting here as I'm probably missing something obvious. I'm receiving:

A NoMethodError occurred in webhook#event:

undefined method 'cancel' for #<User:0x0000000a0b7520>
  vendor/bundle/ruby/1.9.1/gems/activemodel-3.2.11/lib/active_model/attribute_methods.rb:407:in `method_missing'

The full trace is here. And the relevant block of code from stripe_event.rb is:

 events.subscribe 'customer.subscription.deleted' do |event|
    stripe_id = event.data.object['customer']
    subscription = ::Subscription.find_by_stripe_id(stripe_id)
    subscription.subscription_owner.try(:cancel)
 end

However, it looks like it's trying to call :cancel on the User model - why would it do that? Shouldn't it be trying to call it on the SubscriptionsController (here, line 131) which does have a method for :cancel?

Aucun commentaire:

Enregistrer un commentaire