     repo.insert!(struct(resource, params))
     |> insert_or_update_collection(params)
     |> insert_or_update_attributes_for(params)
-  end
-
-  # Constraint errors are not listed in errors. Add them to
-  # errors list
-  defp add_constraints_to_errors(cs) do
-    new_errors = Enum.reduce cs.constraints, cs.errors, fn(constraint, acc) ->
-      unless acc[constraint[:field]] do
-        [{constraint[:field], constraint[:message]} | acc]
-      else
-        acc
-      end
-    end
-    %Ecto.Changeset{cs | errors: new_errors}
   end
 
   def delete(resource, _params) do

          end
        end
        resource
      {:error, cs} ->
        {:error, add_constraints_to_errors(cs)}
    end
  end


            end
            resource
        end
      error -> error
    end
  end

