Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- controller do
- def scoped_collection
- sql = <<-SQL.strip_heredoc
- LEFT JOIN lots on audits.auditable_id = lots.id AND audits.auditable_type = 'Lots::Base'
- LEFT JOIN bills on audits.auditable_id = bills.id AND audits.auditable_type = 'Bill'
- UNION
- SELECT audits.*, lots.*, bills.* FROM audits
- LEFT JOIN lots on audits.associated_id = lots.id AND audits.associated_type = 'Lots::Base'
- LEFT JOIN bills on audits.associated_id = bills.id AND audits.associated_type = 'Bill'
- SQL
- Audit
- .select('audits.*, lots.*, bills.*')
- .joins(sql)
- # .where("lots.id is not null or (bills.id is not null and bills.state != 'hidden')")
- # .order('order by id, id, id')
- # .reorder(:created_at)
- # .limit(LIMIT)
- # .preload(:auditable)
- # .preload(:user)
- end
- PG::UndefinedTable: ERROR: missing FROM-clause entry for table "audits"
- LINE 6: ...s.id AND audits.associated_type = 'Bill' ORDER BY "audits"."...
- ^
- : SELECT audits.*, lots.*, bills.* FROM "audits" LEFT JOIN lots on audits.auditable_id = lots.id AND audits.auditable_type = 'Lots::Base'
- LEFT JOIN bills on audits.auditable_id = bills.id AND audits.auditable_type = 'Bill'
- UNION
- SELECT audits.*, lots.*, bills.* FROM audits
- LEFT JOIN lots on audits.associated_id = lots.id AND audits.associated_type = 'Lots::Base'
- LEFT JOIN bills on audits.associated_id = bills.id AND audits.associated_type = 'Bill' ORDER BY "audits"."id" desc LIMIT 30 OFFSET 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement