mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Render errors in JSON in the schedule correctly
This commit is contained in:
parent
e8261d41bc
commit
a1c7f67735
5 changed files with 32 additions and 37 deletions
|
|
@ -4,25 +4,25 @@ module Admin
|
|||
|
||||
def create
|
||||
if @event_schedule.save
|
||||
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
||||
render json: { event_schedule_id: @event_schedule.id }
|
||||
else
|
||||
render json: { 'status' => "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
if @event_schedule.update(event_schedule_params)
|
||||
render json: { 'status' => 'ok', event_schedule_id: @event_schedule.id }
|
||||
render json: { event_schedule_id: @event_schedule.id }
|
||||
else
|
||||
render json: { 'status' => "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||
render json: { errors: "The event couldn't be scheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
if @event_schedule.destroy
|
||||
render json: { 'status' => 'ok' }
|
||||
render json: {}
|
||||
else
|
||||
render json: { 'status' => "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }
|
||||
render json: { errors: "The event couldn't be unscheduled. #{@event_schedule.errors.full_messages.join('. ')}" }, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue