forked from tildeverse/tilde.news
parent
7c9dcc55a0
commit
29b0f1a243
|
@ -14,7 +14,7 @@ class HatsController < ApplicationController
|
|||
|
||||
@hat_groups = {}
|
||||
|
||||
Hat.all.includes(:user).each do |h|
|
||||
Hat.active.includes(:user).each do |h|
|
||||
@hat_groups[h.hat] ||= []
|
||||
@hat_groups[h.hat].push h
|
||||
end
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
class Hat < ApplicationRecord
|
||||
belongs_to :user
|
||||
belongs_to :granted_by_user, :class_name => "User", :inverse_of => false
|
||||
belongs_to :granted_by_user, class_name: "User", inverse_of: false
|
||||
|
||||
after_create :log_moderation
|
||||
|
||||
validates :user, :granted_by_user, :hat, presence: true
|
||||
validates :hat, :link, length: { maximum: 255 }
|
||||
|
||||
scope :active, -> { joins(:user).where(doffed_at: nil).merge(User.active) }
|
||||
|
||||
def doff_by_user_with_reason(user, reason)
|
||||
m = Moderation.new
|
||||
m.user_id = self.user_id
|
||||
|
|
Loading…
Reference in New Issue