eBooru/app/models/post_report_reason.rb
Earlopain fc7d84affd
[RuboCop] Enable Style/FrozenStringLiteralComment
This reduces allocations on the posts page by about 5%, from basic testing
2024-02-25 18:15:55 +01:00

21 lines
454 B
Ruby

# frozen_string_literal: true
class PostReportReason < ApplicationRecord
belongs_to_creator
validates :reason, uniqueness: { case_sensitive: false }
def self.for_select
reasons = order('id DESC')
reasons = reasons.map {|x| [x.reason, x.id]}
reasons.unshift ['', '']
end
def self.for_select_descriptions
reasons = self.order('id DESC')
js_map = {}
reasons.each {|x| js_map[x.id] = x.description}
js_map
end
end