Handle rails 6 deprecation of update_attributes to update

This commit is contained in:
Eric 2020-05-20 16:03:16 -05:00
parent 0248fb5663
commit 7ccd6870aa
16 changed files with 17 additions and 17 deletions

View file

@ -67,7 +67,7 @@ class CampaignsController < ApplicationController
Time.use_zone(current_nonprofit.timezone || 'UTC') do Time.use_zone(current_nonprofit.timezone || 'UTC') do
campaign_params[:end_datetime] = Chronic.parse(campaign_params[:end_datetime]) if campaign_params[:end_datetime].present? campaign_params[:end_datetime] = Chronic.parse(campaign_params[:end_datetime]) if campaign_params[:end_datetime].present?
end end
current_campaign.update_attributes campaign_params current_campaign.update campaign_params
json_saved current_campaign, 'Successfully updated!' json_saved current_campaign, 'Successfully updated!'
end end

View file

@ -46,7 +46,7 @@ class EventsController < ApplicationController
event_params[:start_datetime] = Chronic.parse(event_params[:start_datetime]) if event_params[:start_datetime].present? event_params[:start_datetime] = Chronic.parse(event_params[:start_datetime]) if event_params[:start_datetime].present?
event_params[:end_datetime] = Chronic.parse(event_params[:end_datetime]) if event_params[:end_datetime].present? event_params[:end_datetime] = Chronic.parse(event_params[:end_datetime]) if event_params[:end_datetime].present?
end end
current_event.update_attributes(event_params) current_event.update(event_params)
json_saved current_event, 'Successfully updated' json_saved current_event, 'Successfully updated'
end end

View file

@ -46,7 +46,7 @@ module Nonprofits
def update def update
@payment = current_nonprofit.payments.find(params[:id]) @payment = current_nonprofit.payments.find(params[:id])
@payment.update_attributes(payment_params) @payment.update(payment_params)
json_saved @payment json_saved @payment
end end

View file

@ -57,7 +57,7 @@ class NonprofitsController < ApplicationController
def update def update
flash[:notice] = 'Update successful!' flash[:notice] = 'Update successful!'
current_nonprofit.update_attributes nonprofit_params.except(:verification_status) current_nonprofit.update nonprofit_params.except(:verification_status)
json_saved current_nonprofit json_saved current_nonprofit
end end

View file

@ -47,7 +47,7 @@ class ProfilesController < ApplicationController
else else
current_user.profile current_user.profile
end end
@profile.update_attributes(profile_params) @profile.update(profile_params)
json_saved @profile, 'Profile updated' json_saved @profile, 'Profile updated'
end end

View file

@ -22,7 +22,7 @@ class TicketLevelsController < ApplicationController
end end
def update def update
current_ticket_level.update_attributes ticket_level_params current_ticket_level.update ticket_level_params
json_saved current_ticket_level, 'Ticket level updated' json_saved current_ticket_level, 'Ticket level updated'
end end

View file

@ -48,7 +48,7 @@ class TicketsController < ApplicationController
# PUT nonprofits/:nonprofit_id/events/:event_id/tickets/:id/add_note # PUT nonprofits/:nonprofit_id/events/:event_id/tickets/:id/add_note
def add_note def add_note
current_nonprofit.tickets.find(params[:id]).update_attributes(note: ticket_params[:note]) current_nonprofit.tickets.find(params[:id]).update(note: ticket_params[:note])
render json: {} render json: {}
end end

View file

@ -25,7 +25,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
def confirm def confirm
@user = User.find(params[:id]) @user = User.find(params[:id])
if @user.valid? && @user.update_attributes(params[:user].except(:confirmation_token)) if @user.valid? && @user.update(params[:user].except(:confirmation_token))
flash[:notice] = 'Your account is all set!' flash[:notice] = 'Your account is all set!'
sign_in @user sign_in @user
redirect_to session[:donor_signup_url] || root_url redirect_to session[:donor_signup_url] || root_url

View file

@ -31,7 +31,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
if current_user.pending_password && params[:user][:password] && params[:user][:password_confirmation] if current_user.pending_password && params[:user][:password] && params[:user][:password_confirmation]
params[:user][:pending_password] = false params[:user][:pending_password] = false
end end
success = current_user.update_attributes(params[:user]) success = current_user.update(params[:user])
errs = current_user.errors.full_messages errs = current_user.errors.full_messages
else else
success = false success = false

View file

@ -25,7 +25,7 @@ module CancelBillingSubscription
end end
billing_plan_id = Settings.default_bp.id billing_plan_id = Settings.default_bp.id
billing_subscription.update_attributes( billing_subscription.update(
billing_plan_id: billing_plan_id, billing_plan_id: billing_plan_id,
status: 'active' status: 'active'
) )

View file

@ -19,7 +19,7 @@ module CreateCampaign
# json_saved campaign, 'Campaign created! Well done.' # json_saved campaign, 'Campaign created! Well done.'
else else
profile_id = params[:campaign][:profile_id] profile_id = params[:campaign][:profile_id]
Profile.find(profile_id).update_attributes params[:profile] Profile.find(profile_id).update params[:profile]
return CreatePeerToPeerCampaign.create(params[:campaign], profile_id) return CreatePeerToPeerCampaign.create(params[:campaign], profile_id)
end end
end end

View file

@ -22,7 +22,7 @@ module CreateCustomFieldJoin
custom_fields.each do |custom_field| custom_fields.each do |custom_field|
existing = supporter.custom_field_joins.find_by_custom_field_master_id(custom_field[:custom_field_master_id]) existing = supporter.custom_field_joins.find_by_custom_field_master_id(custom_field[:custom_field_master_id])
if existing if existing
existing.update_attributes( existing.update(
custom_field_master_id: custom_field[:custom_field_master_id], custom_field_master_id: custom_field[:custom_field_master_id],
value: custom_field[:value] value: custom_field[:value]
) )

View file

@ -75,7 +75,7 @@ module PayRecurringDonation
'old_donation' => true 'old_donation' => true
)) ))
if result['charge']['status'] != 'failed' if result['charge']['status'] != 'failed'
rd.update_attributes(n_failures: 0) rd.update(n_failures: 0)
result['recurring_donation'] = rd result['recurring_donation'] = rd
HoudiniEventPublisher.announce(:recurring_donation_payment_succeeded, donation, donation&.supporter&.locale || 'en') HoudiniEventPublisher.announce(:recurring_donation_payment_succeeded, donation, donation&.supporter&.locale || 'en')
InsertActivities.for_recurring_donations([result['payment']['id']]) InsertActivities.for_recurring_donations([result['payment']['id']])

View file

@ -3,7 +3,7 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
module UpdateCampaignGiftOption module UpdateCampaignGiftOption
def self.update(gift_option, params) def self.update(gift_option, params)
gift_option.update_attributes params gift_option.update params
gift_option gift_option
end end
end end

View file

@ -105,13 +105,13 @@ module UpdateRecurringDonations
def self.update(rd, params) def self.update(rd, params)
params = set_defaults(params) params = set_defaults(params)
if params[:donation] if params[:donation]
rd.donation.update_attributes(params[:donation]) rd.donation.update(params[:donation])
return rd.donation unless rd.donation.valid? return rd.donation unless rd.donation.valid?
params = params.except(:donation) params = params.except(:donation)
end end
rd.update_attributes(params) rd.update(params)
rd rd
end end

View file

@ -3,7 +3,7 @@
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later # License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
module UpdateSupporter module UpdateSupporter
def self.from_info(supporter, params) def self.from_info(supporter, params)
supporter.update_attributes(params) supporter.update(params)
# GeocodeModel.delay.geocode(supporter) # GeocodeModel.delay.geocode(supporter)
supporter supporter
end end