mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
Wizard: Server Side Validation + Finished Step
This commit is contained in:
@ -9,7 +9,16 @@ class StepsController < ApplicationController
|
||||
def update
|
||||
updater = Wizard::StepUpdater.new(current_user, params[:id])
|
||||
updater.update(params[:fields])
|
||||
render nothing: true
|
||||
|
||||
if updater.success?
|
||||
render json: success_json
|
||||
else
|
||||
errors = []
|
||||
updater.errors.messages.each do |field, msg|
|
||||
errors << {field: field, description: msg.join }
|
||||
end
|
||||
render json: { errors: errors }, status: 422
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user