eBooru/app/models/favorite.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

17 lines
399 B
Ruby

# frozen_string_literal: true
class Favorite < ApplicationRecord
class Error < Exception
end
class HiddenError < User::PrivilegeError
def initialize(msg = "This users favorites are hidden")
super
end
end
belongs_to :post
belongs_to :user
user_status_counter :favorite_count, foreign_key: :user_id
scope :for_user, ->(user_id) {where("user_id = #{user_id.to_i}")}
end