Use Rails 7.1 normalizes
feature (#27521)
This commit is contained in:
parent
50b7ea810e
commit
714e3ae5b5
5 changed files with 7 additions and 25 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue