Use Rails 7.1 normalizes feature (#27521)

This commit is contained in:
Matt Jankowski 2023-10-24 06:06:10 -04:00 committed by GitHub
parent 50b7ea810e
commit 714e3ae5b5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 25 deletions

View file

@ -27,7 +27,7 @@ class AccountWarning < ApplicationRecord
suspend: 4_000,
}, _suffix: :action
before_validation :before_validate
normalizes :text, with: ->(text) { text.to_s }, apply_to_nil: true
belongs_to :account, inverse_of: :account_warnings
belongs_to :target_account, class_name: 'Account', inverse_of: :strikes
@ -50,10 +50,4 @@ class AccountWarning < ApplicationRecord
def to_log_human_identifier
target_account.acct
end
private
def before_validate
self.text = '' if text.blank?
end
end