2023-03-04 22:38:38 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Achievements
|
|
|
|
class Achievement < ApplicationRecord
|
|
|
|
include Avatarable
|
|
|
|
include StripAttribute
|
2023-04-23 21:23:45 +05:30
|
|
|
include IgnorableColumns
|
|
|
|
|
|
|
|
ignore_column :revokable, remove_with: '15.11', remove_after: '2023-04-22'
|
2023-03-04 22:38:38 +05:30
|
|
|
|
|
|
|
belongs_to :namespace, inverse_of: :achievements, optional: false
|
|
|
|
|
2023-03-17 16:20:25 +05:30
|
|
|
has_many :user_achievements, inverse_of: :achievement
|
|
|
|
has_many :users, through: :user_achievements, inverse_of: :achievements
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
strip_attributes! :name, :description
|
|
|
|
|
|
|
|
validates :name,
|
|
|
|
presence: true,
|
|
|
|
length: { maximum: 255 },
|
|
|
|
uniqueness: { case_sensitive: false, scope: [:namespace_id] }
|
|
|
|
validates :description, length: { maximum: 1024 }
|
|
|
|
end
|
|
|
|
end
|