Add and apply ArgumentAlignment rubocop rule

We're choosing the default `with_first_argument` style because it's the
one we use the most.
This commit is contained in:
Javi Martín
2023-07-01 17:37:58 +02:00
parent 32b1fc53e1
commit 629e208e9d
202 changed files with 907 additions and 830 deletions

View File

@@ -6,25 +6,25 @@ module Attachable
attr_accessor :cached_attachment
validates :attachment,
presence: true,
file_content_type: {
allow: ->(record) { record.accepted_content_types },
if: -> { association_class && attachment.attached? },
message: ->(record, *) do
I18n.t("#{record.model_name.plural}.errors.messages.wrong_content_type",
content_type: record.attachment_content_type,
accepted_content_types: record.class.humanized_accepted_content_types)
end
},
file_size: {
less_than_or_equal_to: ->(record) { record.max_file_size.megabytes },
if: -> { association_class && attachment.attached? },
message: ->(record, *) do
I18n.t("#{record.model_name.plural}.errors.messages.in_between",
min: "0 Bytes",
max: "#{record.max_file_size} MB")
end
}
presence: true,
file_content_type: {
allow: ->(record) { record.accepted_content_types },
if: -> { association_class && attachment.attached? },
message: ->(record, *) do
I18n.t("#{record.model_name.plural}.errors.messages.wrong_content_type",
content_type: record.attachment_content_type,
accepted_content_types: record.class.humanized_accepted_content_types)
end
},
file_size: {
less_than_or_equal_to: ->(record) { record.max_file_size.megabytes },
if: -> { association_class && attachment.attached? },
message: ->(record, *) do
I18n.t("#{record.model_name.plural}.errors.messages.in_between",
min: "0 Bytes",
max: "#{record.max_file_size} MB")
end
}
before_validation :set_attachment_from_cached_attachment, if: -> { cached_attachment.present? }
end

View File

@@ -3,9 +3,9 @@ module Relationable
included do
has_many :related_contents,
as: :parent_relationable,
inverse_of: :parent_relationable,
dependent: :destroy
as: :parent_relationable,
inverse_of: :parent_relationable,
dependent: :destroy
end
def find_related_content(relationable)