Fix this: https://danbooru.donmai.us/uploads.json?search[media_assets][md5]=b83daa7f1ae7e4127b1befd32f71ba10 failing with an ActiveRecord::StatementInvalid error. The bug was that for a `has_many through: ...` association, like `has_many :media_assets, through: :upload_media_assets`, we weren't joining on the associated table properly so we ended up generating invalid SQL.
12 lines
280 B
Ruby
12 lines
280 B
Ruby
# frozen_string_literal: true
|
|
|
|
class UploadMediaAsset < ApplicationRecord
|
|
belongs_to :upload
|
|
belongs_to :media_asset
|
|
|
|
def self.search(params)
|
|
q = search_attributes(params, :id, :created_at, :updated_at, :upload, :media_asset)
|
|
q.apply_default_order(params)
|
|
end
|
|
end
|