diff --git a/CHANGELOG.md b/CHANGELOG.md index 80bd4367b..976a376c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix a bug: invalid link to the user's manual - Fix a bug: unable to sync coupons on stripe - Fix a bug: ignored coupon when booking an event with card payment +- Fix a bug: deleting a coupon displays an error message ## v5.0.4 2021 June 15 diff --git a/app/models/coupon.rb b/app/models/coupon.rb index 235997423..744ad35ba 100644 --- a/app/models/coupon.rb +++ b/app/models/coupon.rb @@ -6,7 +6,7 @@ class Coupon < ApplicationRecord has_many :payment_schedule after_create :create_gateway_coupon - after_commit :delete_gateway_coupon, on: [:destroy] + before_destroy :delete_gateway_coupon validates :name, presence: true validates :code, presence: true diff --git a/config/routes.rb b/config/routes.rb index a5614461c..826887a0b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -78,9 +78,10 @@ Rails.application.routes.draw do resources :prices, only: %i[index update] do post 'compute', on: :collection end - resources :coupons - post 'coupons/validate' => 'coupons#validate' - post 'coupons/send' => 'coupons#send_to' + resources :coupons do + post 'validate', action: 'validate', on: :collection + post 'send', action: 'send_to', on: :collection + end resources :trainings_pricings, only: %i[index update]