mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 01:24:48 +08:00
DEV: Apply syntax_tree formatting to app/*
This commit is contained in:
@ -4,16 +4,20 @@ class SidebarSectionLink < ActiveRecord::Base
|
||||
belongs_to :user
|
||||
belongs_to :linkable, polymorphic: true
|
||||
|
||||
validates :user_id, presence: true, uniqueness: { scope: [:linkable_type, :linkable_id] }
|
||||
validates :user_id, presence: true, uniqueness: { scope: %i[linkable_type linkable_id] }
|
||||
validates :linkable_id, presence: true
|
||||
validates :linkable_type, presence: true
|
||||
validate :ensure_supported_linkable_type, if: :will_save_change_to_linkable_type?
|
||||
|
||||
SUPPORTED_LINKABLE_TYPES = %w{Category Tag}
|
||||
SUPPORTED_LINKABLE_TYPES = %w[Category Tag]
|
||||
|
||||
private def ensure_supported_linkable_type
|
||||
if (!SUPPORTED_LINKABLE_TYPES.include?(self.linkable_type)) || (self.linkable_type == 'Tag' && !SiteSetting.tagging_enabled)
|
||||
self.errors.add(:linkable_type, I18n.t("activerecord.errors.models.sidebar_section_link.attributes.linkable_type.invalid"))
|
||||
if (!SUPPORTED_LINKABLE_TYPES.include?(self.linkable_type)) ||
|
||||
(self.linkable_type == "Tag" && !SiteSetting.tagging_enabled)
|
||||
self.errors.add(
|
||||
:linkable_type,
|
||||
I18n.t("activerecord.errors.models.sidebar_section_link.attributes.linkable_type.invalid"),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user