app/controllers/data_objects_controller.rb
# PUT /data_objects/:id
# NOTE we don't actually edit the data object we create a new one and unpublish the old one.
# old @data_object is loaded in before_filter :load_data_object
PUT /data_objects/:id
NOTE we don't actually edit the data object we create a new one and unpublish the old one.
PUT / data_objects / : id NOTE we don ' t actually edit the data object we create a new one and unpublish the old one .
def update
    @references = params[:references]
    if DataObject.spammy?(params, current_user, refs: @references)
      update_failed(I18n.t(:error_violates_tos)) and return
    end
    DataObject.with_master do
      if @data_object.users_data_object.user_id != current_user.id
        update_failed(I18n.t(:dato_update_users_text_not_owner_exception)) and return
      end
    end
    new_data_object = @data_object.replicate(params[:data_object], user: current_user, toc_id: toc_id,
                                             link_type_id: link_type_id, link_object: params[:commit_link])
    if new_data_object.nil?
      update_failed(I18n.t(:dato_update_user_text_error)) and return
    elsif new_data_object.errors.any?
      @data_object = new_data_object 
      update_failed(I18n.t(:dato_update_user_text_error)) and return
    else
      add_references(new_data_object)
      redirect_to data_object_path(new_data_object), status: :moved_permanently
    end
  end
def update @references = params [ :references ] if DataObject . spammy? ( params , current_user , refs : @references ) update_failed ( I18n . t ( :error_violates_tos ) ) and return end DataObject . with_master do if @data_object . users_data_object . user_id != current_user . id update_failed ( I18n . t ( :dato_update_users_text_not_owner_exception ) ) and return end end new_data_object = @data_object . replicate ( params [ :data_object ] , user : current_user , toc_id : toc_id , link_type_id : link_type_id , link_object : params [ :commit_link ] ) if new_data_object . nil? update_failed ( I18n . t ( :dato_update_user_text_error ) ) and return elsif new_data_object . errors . any? @data_object = new_data_object update_failed ( I18n . t ( :dato_update_user_text_error ) ) and return else add_references ( new_data_object ) redirect_to data_object_path ( new_data_object ) , status : :moved_permanently end end
PUT /data_objects/:id
NOTE we don't actually edit the data object we create a new one and unpublish the old one.
PUT / data_objects / : id NOTE we don ' t actually edit the data object we create a new one and unpublish the old one .
# Important that you're getting the latest version: # Note: replicate doesn't actually update, it creates a new data_object # We want to show the errors...