mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
[bug] a message tells that creating a new plan fails, but it worked
This commit is contained in:
parent
9f2e33f2ea
commit
569be57a1f
@ -1,5 +1,7 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: a message tells that creating a new plan fails, but it worked
|
||||
|
||||
## v5.0.3 2021 June 14
|
||||
|
||||
- Updated user's manual for v5
|
||||
|
@ -26,11 +26,11 @@ class API::PlansController < API::ApiController
|
||||
type = plan_params[:type]
|
||||
partner = params[:plan][:partner_id].empty? ? nil : User.find(params[:plan][:partner_id])
|
||||
|
||||
res = PlansService.create(type, partner, plan_params)
|
||||
if res.errors
|
||||
render json: res.errors, status: :unprocessable_entity
|
||||
plan = PlansService.create(type, partner, plan_params)
|
||||
if plan.errors.keys.count.positive?
|
||||
render json: plan.errors, status: :unprocessable_entity
|
||||
else
|
||||
render json: res, status: :created
|
||||
render json: plan, status: :created
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,11 +14,8 @@ class PlansService
|
||||
plan = type.constantize.new(params)
|
||||
if plan.save
|
||||
partner&.add_role :partner, plan
|
||||
plan
|
||||
else
|
||||
puts plan.errors
|
||||
{ errors: plan.errors }
|
||||
end
|
||||
plan
|
||||
end
|
||||
rescue PaymentGatewayError => e
|
||||
{ errors: e.message }
|
||||
|
Loading…
x
Reference in New Issue
Block a user