app/controllers/uploader/attachments_controller.rb in rails-uploader-0.0.3 vs app/controllers/uploader/attachments_controller.rb in rails-uploader-0.0.4
- old
+ new
@@ -19,17 +19,17 @@
protected
def find_klass
@klass = params[:klass].blank? ? nil : params[:klass].safe_constantize
- raise ActiveRecord::RecordNotFound.new("Class not found #{params[:klass]}") if @klass.nil?
+ raise ActionController::RoutingError.new("Class not found #{params[:klass]}") if @klass.nil?
end
def render_resourse(record, status = 200)
if record.errors.empty?
- render_json(record.to_json, status)
+ render_json([record].to_json(:root => false), status)
else
- render_json(record.errors.to_json, 422)
+ render_json([record.errors].to_json, 422)
end
end
def render_json(body, status = 200)
self.status = status