Replace deprecated update_attributes with update.
https://rubyinrails.com/2019/04/09/rails-6-1-activerecord-deprecates-update-attributes-methods/ DEPRECATION WARNING: update_attributes! is deprecated and will be removed from Rails 6.1 (please, use update! instead)
This commit is contained in:
@@ -51,7 +51,7 @@ class NotesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@note = Note.find(params[:id])
|
||||
@note.update_attributes(:is_active => false)
|
||||
@note.update(is_active: false)
|
||||
respond_with(@note)
|
||||
end
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ class WikiPagesController < ApplicationController
|
||||
|
||||
def destroy
|
||||
@wiki_page = WikiPage.find(params[:id])
|
||||
@wiki_page.update_attributes(:is_deleted => true)
|
||||
@wiki_page.update(is_deleted: true)
|
||||
respond_with(@wiki_page)
|
||||
end
|
||||
|
||||
|
||||
@@ -279,14 +279,7 @@ class Artist < ApplicationRecord
|
||||
|
||||
def merge_version
|
||||
prev = versions.last
|
||||
prev.update_attributes(
|
||||
:name => name,
|
||||
:urls => url_array,
|
||||
:is_active => is_active,
|
||||
:is_banned => is_banned,
|
||||
:other_names => other_names,
|
||||
:group_name => group_name
|
||||
)
|
||||
prev.update(name: name, urls: url_array, is_active: is_active, is_banned: is_banned, other_names: other_names, group_name: group_name)
|
||||
end
|
||||
|
||||
def merge_version?
|
||||
@@ -427,7 +420,7 @@ class Artist < ApplicationRecord
|
||||
Post.tag_match(name).where("true /* Artist.unban */").each do |post|
|
||||
post.unban!
|
||||
fixed_tags = post.tag_string.sub(/(?:\A| )banned_artist(?:\Z| )/, " ").strip
|
||||
post.update_attributes(:tag_string => fixed_tags)
|
||||
post.update(tag_string: fixed_tags)
|
||||
end
|
||||
rescue Post::SearchError
|
||||
# swallow
|
||||
|
||||
@@ -174,7 +174,7 @@ class FavoriteGroup < ApplicationRecord
|
||||
return if contains?(post_id)
|
||||
|
||||
clear_post_id_array
|
||||
update_attributes(:post_ids => add_number_to_string(post_id, post_ids))
|
||||
update(post_ids: add_number_to_string(post_id, post_ids))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -184,7 +184,7 @@ class FavoriteGroup < ApplicationRecord
|
||||
return unless contains?(post_id)
|
||||
|
||||
clear_post_id_array
|
||||
update_attributes(:post_ids => remove_number_from_string(post_id, post_ids))
|
||||
update(post_ids: remove_number_from_string(post_id, post_ids))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ class ForumTopic < ApplicationRecord
|
||||
|
||||
def merge(topic)
|
||||
ForumPost.where(:id => self.posts.map(&:id)).update_all(:topic_id => topic.id)
|
||||
topic.update_attributes(:response_count => topic.response_count + self.posts.length, :updater_id => CurrentUser.id)
|
||||
topic.update(response_count: topic.response_count + self.posts.length, updater_id: CurrentUser.id)
|
||||
self.update_columns(:response_count => 0, :is_deleted => true, :updater_id => CurrentUser.id)
|
||||
end
|
||||
|
||||
|
||||
@@ -139,14 +139,7 @@ class Note < ApplicationRecord
|
||||
|
||||
def merge_version
|
||||
prev = versions.last
|
||||
prev.update_attributes(
|
||||
:x => x,
|
||||
:y => y,
|
||||
:width => width,
|
||||
:height => height,
|
||||
:is_active => is_active,
|
||||
:body => body
|
||||
)
|
||||
prev.update(x: x, y: y, width: width, height: height, is_active: is_active, body: body)
|
||||
end
|
||||
|
||||
def merge_version?(updater_id)
|
||||
|
||||
@@ -142,9 +142,7 @@ class TagAlias < TagRelationship
|
||||
escaped_antecedent_name = Regexp.escape(antecedent_name)
|
||||
fixed_tags = post.tag_string.sub(/(?:\A| )#{escaped_antecedent_name}(?:\Z| )/, " #{consequent_name} ").strip
|
||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||
post.update_attributes(
|
||||
:tag_string => fixed_tags
|
||||
)
|
||||
post.update(tag_string: fixed_tags)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -154,9 +154,7 @@ class TagImplication < TagRelationship
|
||||
Post.raw_tag_match(antecedent_name).where("true /* TagImplication#update_posts */").find_each do |post|
|
||||
fixed_tags = "#{post.tag_string} #{descendant_names_string}".strip
|
||||
CurrentUser.scoped(creator, creator_ip_addr) do
|
||||
post.update_attributes(
|
||||
:tag_string => fixed_tags
|
||||
)
|
||||
post.update(tag_string: fixed_tags)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -47,7 +47,7 @@ class UserNameChangeRequest < ApplicationRecord
|
||||
end
|
||||
|
||||
def approve!
|
||||
update_attributes(:status => "approved", :approver_id => CurrentUser.user.id)
|
||||
update(status: "approved", approver_id: CurrentUser.user.id)
|
||||
user.update_attribute(:name, desired_name)
|
||||
body = "Your name change request has been approved. Be sure to log in with your new user name."
|
||||
Dmail.create_automated(:title => "Name change request approved", :body => body, :to_id => user_id)
|
||||
@@ -56,7 +56,7 @@ class UserNameChangeRequest < ApplicationRecord
|
||||
end
|
||||
|
||||
def reject!(reason)
|
||||
update_attributes(:status => "rejected", :rejection_reason => reason)
|
||||
update(status: "rejected", rejection_reason: reason)
|
||||
body = "Your name change request has been rejected for the following reason: #{rejection_reason}"
|
||||
Dmail.create_automated(:title => "Name change request rejected", :body => body, :to_id => user_id)
|
||||
end
|
||||
|
||||
@@ -176,13 +176,7 @@ class WikiPage < ApplicationRecord
|
||||
|
||||
def merge_version
|
||||
prev = versions.last
|
||||
prev.update_attributes(
|
||||
:title => title,
|
||||
:body => body,
|
||||
:is_locked => is_locked,
|
||||
:is_deleted => is_deleted,
|
||||
:other_names => other_names
|
||||
)
|
||||
prev.update(title: title, body: body, is_locked: is_locked, is_deleted: is_deleted, other_names: other_names)
|
||||
end
|
||||
|
||||
def merge_version?
|
||||
|
||||
Reference in New Issue
Block a user