Files
danbooru/app/models/artist_version.rb
evazion ea45e44e10 search: remove legacy 'search[sort]' params.
Remove support for the `search[sort]` param on certain index pages. This
hasn't been used for years, and it caused the `search[order]=` param to
be added to pagination links even when the order was blank.
2020-01-31 02:43:08 -06:00

30 lines
649 B
Ruby

class ArtistVersion < ApplicationRecord
array_attribute :urls
array_attribute :other_names
belongs_to_updater
belongs_to :artist
module SearchMethods
def search(params)
q = super
q = q.search_attributes(params, :updater, :is_active, :is_banned, :artist_id, :name, :group_name)
if params[:order] == "name"
q = q.order("artist_versions.name").default_order
else
q = q.apply_default_order(params)
end
q
end
end
extend SearchMethods
def previous
ArtistVersion.where("artist_id = ? and created_at < ?", artist_id, created_at).order("created_at desc").first
end
end