You need to Hanlde your else part with Proper error condition handling
Simple Put will not do the Job
There are following options to handle it
1st by ony Render the JSON
if @seller_profile.save
redirect_to home_index_path
else
render json: @seller_profile.errors.to_json.to_json
end
2nd redirect back with error in notification
if @seller_profile.save
redirect_to home_index_path
else
flash[:error] = @restaurant.errors
redirect_to :back
end
3rd Option to use both Option of Render and Redirect at Same Time
if @seller_profile.save
redirect_to home_index_path
else
respond_to do |format|
format.html { redirect_to :back , flash[:error] = @restaurant.errors }
format.json { render json: @seller_profile.errors.to_json.to_json }
end
end
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…