replace deprecated update_attributes with update

This commit is contained in:
viehlieb 2022-10-13 18:25:52 +02:00 committed by Patrick Gansterer
parent eb45a2bf21
commit 3ffdb424d5
28 changed files with 52 additions and 53 deletions

View file

@ -23,7 +23,7 @@ class Admin::BankAccountsController < Admin::BaseController
def update
@bank_account = BankAccount.find(params[:id])
if @bank_account.update_attributes(params[:bank_account])
if @bank_account.update(params[:bank_account])
redirect_to update_bank_accounts_admin_finances_url, :status => 303
else
render :action => 'new', :layout => false

View file

@ -23,7 +23,7 @@ class Admin::FinancialTransactionClassesController < Admin::BaseController
def update
@financial_transaction_class = FinancialTransactionClass.find(params[:id])
if @financial_transaction_class.update_attributes(params[:financial_transaction_class])
if @financial_transaction_class.update(params[:financial_transaction_class])
redirect_to update_transaction_types_admin_finances_url, status: 303
else
render action: 'new', layout: false

View file

@ -24,7 +24,7 @@ class Admin::FinancialTransactionTypesController < Admin::BaseController
def update
@financial_transaction_type = FinancialTransactionType.find(params[:id])
if @financial_transaction_type.update_attributes(params[:financial_transaction_type])
if @financial_transaction_type.update(params[:financial_transaction_type])
redirect_to update_transaction_types_admin_finances_url, status: 303
else
render action: 'new', layout: false

View file

@ -26,7 +26,7 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
goa.update_quantities((create_params[:quantity] || 0).to_i, (create_params[:tolerance] || 0).to_i)
oa.update_results!
go.update_price!
go.update_attributes! updated_by: current_user
go.update!(updated_by: current_user)
end
render_goa_with_oa(goa)
end
@ -38,7 +38,7 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
goa.update_quantities((update_params[:quantity] || goa.quantity).to_i, (update_params[:tolerance] || goa.tolerance).to_i)
goa.order_article.update_results!
goa.group_order.update_price!
goa.group_order.update_attributes! updated_by: current_user
goa.group_order.update!(updated_by: current_user)
end
render_goa_with_oa(goa)
end
@ -50,7 +50,7 @@ class Api::V1::User::GroupOrderArticlesController < Api::V1::BaseController
goa.destroy!
goa.order_article.update_results!
goa.group_order.update_price!
goa.group_order.update_attributes! updated_by: current_user
goa.group_order.update!(updated_by: current_user)
end
render_goa_with_oa(nil, goa.order_article)
end

View file

@ -64,7 +64,7 @@ class ArticlesController < ApplicationController
def update
@article = Article.find(params[:id])
if @article.update_attributes(params[:article])
if @article.update(params[:article])
render :layout => false
else
render :action => 'new', :layout => false
@ -93,7 +93,7 @@ class ArticlesController < ApplicationController
# Update other article attributes...
@articles = Article.find(params[:articles].keys)
@articles.each do |article|
unless article.update_attributes(params[:articles][article.id.to_s])
unless article.update(params[:articles][article.id.to_s])
invalid_articles = true unless invalid_articles # Remember that there are validation errors
end
end

View file

@ -33,7 +33,7 @@ class DeliveriesController < ApplicationController
def update
@delivery = Delivery.find(params[:id])
if @delivery.update_attributes(params[:delivery])
if @delivery.update(params[:delivery])
flash[:notice] = I18n.t('deliveries.update.notice')
redirect_to [@supplier, @delivery]
else

View file

@ -51,7 +51,7 @@ class Finance::BalancingController < Finance::BaseController
def update_note
@order = Order.find(params[:id])
if @order.update_attributes(params[:order])
if @order.update(params[:order])
render :layout => false
else
render :action => :edit_note, :layout => false
@ -65,7 +65,7 @@ class Finance::BalancingController < Finance::BaseController
def update_transport
@order = Order.find(params[:id])
@order.update_attributes! params[:order]
@order.update!(params[:order])
redirect_to new_finance_order_path(order_id: @order.id)
rescue => error
redirect_to new_finance_order_path(order_id: @order.id), alert: t('errors.general_msg', msg: error.message)

View file

@ -63,7 +63,7 @@ class Finance::InvoicesController < ApplicationController
end
def update
if @invoice.update_attributes(params[:invoice])
if @invoice.update(params[:invoice])
redirect_to [:finance, @invoice], notice: I18n.t('finance.update.notice')
else
fill_deliveries_and_orders_collection @invoice.id, @invoice.supplier_id

View file

@ -12,7 +12,7 @@ class Foodcoop::WorkgroupsController < ApplicationController
def update
@workgroup = Workgroup.find(params[:id])
if @workgroup.update_attributes(params[:workgroup])
if @workgroup.update(params[:workgroup])
redirect_to foodcoop_workgroups_url, :notice => I18n.t('workgroups.update.notice')
else
render :action => 'edit'

View file

@ -19,7 +19,7 @@ class GroupOrderArticlesController < ApplicationController
goa = GroupOrderArticle.where(group_order_id: @group_order_article.group_order_id,
order_article_id: @order_article.id).first
if goa && goa.update_attributes(params[:group_order_article])
if goa && goa.update(params[:group_order_article])
@group_order_article = goa
update_summaries(@group_order_article)
@ -38,7 +38,7 @@ class GroupOrderArticlesController < ApplicationController
if params[:delta]
@group_order_article.update_attribute :result, [@group_order_article.result + params[:delta].to_f, 0].max
else
@group_order_article.update_attributes(params[:group_order_article])
@group_order_article.update(params[:group_order_article])
end
update_summaries(@group_order_article)

View file

@ -23,8 +23,8 @@ class HomeController < ApplicationController
end
def update_profile
if @current_user.update_attributes(user_params)
@current_user.ordergroup.update_attributes(ordergroup_params) if ordergroup_params
if @current_user.update(user_params)
@current_user.ordergroup.update(ordergroup_params) if ordergroup_params
session[:locale] = @current_user.locale
redirect_to my_profile_url, notice: I18n.t('home.changes_saved')
else

View file

@ -94,7 +94,7 @@ class OrdersController < ApplicationController
# Update an existing order.
def update
@order = Order.find params[:id]
if @order.update_attributes params[:order].merge(updated_by: current_user)
if @order.update(params[:order].merge(updated_by: current_user))
flash[:notice] = I18n.t('orders.update.notice')
redirect_to :action => 'show', :id => @order
else

View file

@ -54,7 +54,7 @@ class StockitController < ApplicationController
def update
@stock_article = StockArticle.find(params[:id])
@stock_article.update_attributes!(params[:stock_article])
@stock_article.update!(params[:stock_article])
render :layout => false
rescue ActiveRecord::RecordInvalid
render :action => 'edit', :layout => false

View file

@ -41,7 +41,7 @@ class SuppliersController < ApplicationController
def update
@supplier = Supplier.find(params[:id])
if @supplier.update_attributes(supplier_params)
if @supplier.update(supplier_params)
flash[:notice] = I18n.t('suppliers.update.notice')
redirect_to @supplier
else