Merge branch 'master' into 2871-preload-objects
[arvados.git] / apps / workbench / app / controllers / application_controller.rb
index 99bb2ca866e415a414f442ef973e9740c6e04d0c..c9a761fe232d2a73a3a0a729f288eb4e63c056fa 100644 (file)
@@ -145,9 +145,18 @@ class ApplicationController < ActionController::Base
     @new_resource_attrs ||= params[model_class.to_s.underscore.singularize]
     @new_resource_attrs ||= {}
     @new_resource_attrs.reject! { |k,v| k.to_s == 'uuid' }
-    @object ||= model_class.new @new_resource_attrs
-    @object.save!
-    show
+    @object ||= model_class.new @new_resource_attrs, params["options"]
+    if @object.save
+      respond_to do |f|
+        f.json { render json: @object.attributes.merge(href: url_for(@object)) }
+        f.html {
+          redirect_to @object
+        }
+        f.js { render }
+      end
+    else
+      self.render_error status: 422
+    end
   end
 
   def destroy