Rename update_attributes to update #rails4

This commit is contained in:
Luis Ramos
2020-06-22 13:15:36 +01:00
parent 8a61257547
commit f848a89a00
62 changed files with 168 additions and 168 deletions

View File

@@ -11,7 +11,7 @@ module Api
@customer = Customer.find(params[:id])
authorize! :update, @customer
if @customer.update_attributes(params[:customer])
if @customer.update(params[:customer])
render json: @customer, serializer: CustomerSerializer, status: :ok
else
invalid_resource!(@customer)

View File

@@ -14,7 +14,7 @@ module Api
def destroy
return respond_with_conflict(error: destroy_attachment_does_not_exist_error_message) unless @enterprise.public_send("#{attachment_name}?")
@enterprise.update_attributes!(attachment_name => nil)
@enterprise.update!(attachment_name => nil)
render json: @enterprise, serializer: Admin::EnterpriseSerializer, spree_current_user: spree_current_user
end

View File

@@ -25,7 +25,7 @@ module Api
@enterprise = Enterprise.find_by(permalink: params[:id]) || Enterprise.find(params[:id])
authorize! :update, @enterprise
if @enterprise.update_attributes(params[:enterprise])
if @enterprise.update(params[:enterprise])
render text: @enterprise.id, status: :ok
else
invalid_resource!(@enterprise)
@@ -36,9 +36,9 @@ module Api
@enterprise = Enterprise.find_by(permalink: params[:id]) || Enterprise.find(params[:id])
authorize! :update, @enterprise
if params[:logo] && @enterprise.update_attributes( logo: params[:logo] )
if params[:logo] && @enterprise.update( logo: params[:logo] )
render text: @enterprise.logo.url(:medium), status: :ok
elsif params[:promo] && @enterprise.update_attributes( promo_image: params[:promo] )
elsif params[:promo] && @enterprise.update( promo_image: params[:promo] )
render text: @enterprise.promo_image.url(:medium), status: :ok
else
invalid_resource!(@enterprise)

View File

@@ -11,7 +11,7 @@ module Api
render json: @image, serializer: ImageSerializer, status: :created
else
@image = @product.images.first
@image.update_attributes(attachment: params[:file])
@image.update(attachment: params[:file])
render json: @image, serializer: ImageSerializer, status: :ok
end
end

View File

@@ -32,7 +32,7 @@ module Api
def update
authorize! :update, Spree::Product
@product = find_product(params[:id])
if @product.update_attributes(params[:product])
if @product.update(params[:product])
render json: @product, serializer: Api::Admin::ProductSerializer, status: :ok
else
invalid_resource!(@product)

View File

@@ -30,7 +30,7 @@ module Api
@shipment.adjustment.open
end
@shipment.update_attributes(params[:shipment])
@shipment.update(params[:shipment])
if unlock == 'yes'
@shipment.adjustment.close
@@ -88,7 +88,7 @@ module Api
def find_and_update_shipment
@shipment = @order.shipments.find_by!(number: params[:id])
@shipment.update_attributes(params[:shipment])
@shipment.update(params[:shipment])
@shipment.reload
end

View File

@@ -44,7 +44,7 @@ module Api
def update
authorize! :update, Spree::Taxon
if taxon.update_attributes(params[:taxon])
if taxon.update(params[:taxon])
render json: taxon, serializer: Api::TaxonSerializer, status: :ok
else
invalid_resource!(taxon)

View File

@@ -28,7 +28,7 @@ module Api
def update
authorize! :update, Spree::Variant
@variant = scope.find(params[:id])
if @variant.update_attributes(params[:variant])
if @variant.update(params[:variant])
render json: @variant, serializer: Api::VariantSerializer, status: :ok
else
invalid_resource!(@product)