Files
danbooru/app/models/wiki_page_version.rb
evazion 0ca726802f Fix #3430: Accept the search[id] param in all controllers.
* Allow every controller to take the `search[id]` param.

* Parse the `search[id]` param the same way that the `id:<N>` metatag is
  parsed. So `search[id]=1,2,3`, `search[id]=<42`, `search[id]=1..10`, for
  example, are all accepted.
2017-12-17 17:36:52 -06:00

47 lines
962 B
Ruby

class WikiPageVersion < ApplicationRecord
belongs_to :wiki_page
belongs_to :updater, :class_name => "User"
belongs_to :artist
attr_accessible :wiki_page_id, :title, :body, :is_locked, :is_deleted, :updater_id, :updater_ip_addr, :version, :other_names
delegate :visible?, :to => :wiki_page
module SearchMethods
def for_user(user_id)
where("updater_id = ?", user_id)
end
def search(params)
q = super
return q if params.blank?
if params[:updater_id].present?
q = q.for_user(params[:updater_id].to_i)
end
if params[:wiki_page_id].present?
q = q.where("wiki_page_id = ?", params[:wiki_page_id].to_i)
end
q
end
end
extend SearchMethods
def updater_name
User.id_to_name(updater_id)
end
def pretty_title
title.tr("_", " ")
end
def category_name
Tag.category_for(title)
end
def other_names_array
other_names.to_s.scan(/\S+/)
end
end