Files
danbooru/app/models/artist_commentary_version.rb
evazion 1889864049 /artist_commentary_versions: show post thumbnails.
Show thumbnails in the /artist_commentary_versions listing. Don't show
thumbnails when viewing the version history of a single post.
2017-06-25 10:27:43 -05:00

32 lines
796 B
Ruby

class ArtistCommentaryVersion < ApplicationRecord
before_validation :initialize_updater
belongs_to :post
belongs_to :updater, :class_name => "User"
scope :for_user, lambda {|user_id| where("updater_id = ?", user_id)}
attr_accessible :post_id, :original_title, :original_description, :translated_title, :translated_description
def self.search(params)
q = where("true")
params = {} if params.blank?
if params[:updater_id]
q = q.where("updater_id = ?", params[:updater_id].to_i)
end
if params[:post_id]
q = q.where("post_id = ?", params[:post_id].to_i)
end
q
end
def initialize_updater
self.updater_id = CurrentUser.id
self.updater_ip_addr = CurrentUser.ip_addr
end
def updater_name
User.id_to_name(updater_id)
end
end