Files
danbooru/app/models/news_update.rb
evazion a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00

21 lines
483 B
Ruby

# frozen_string_literal: true
class NewsUpdate < ApplicationRecord
belongs_to :creator, class_name: "User"
belongs_to_updater
scope :recent, -> {where("created_at >= ?", 2.weeks.ago).order("created_at desc").limit(5)}
def self.visible(user)
if user.is_admin?
all
else
none
end
end
def self.search(params)
q = search_attributes(params, :id, :created_at, :updated_at, :message, :creator, :updater)
q.apply_default_order(params)
end
end