Wizard: Server Side Validation + Finished Step

This commit is contained in:
Robin Ward
2016-08-31 13:35:49 -04:00
parent be1d74d207
commit 9f12b571ef
35 changed files with 260 additions and 62 deletions

View File

@ -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