Skip to content

Instantly share code, notes, and snippets.

@shows = presenter(:shows) do |with|
with.maximum_size = 3
with.options.scope = :upcoming
end
class Presenters::Shows < Brentano::Presenter
class_attribute :allowed_scopes, :absolute_limit
self.allowed_scopes = [ :upcoming, :past ]
self.absolute_limit = Gigmaven::Application.config.query_limit
def relation
subject.events.includes([
:primary_photo,
:flyer,
negotiations = Negotiation.arel_table
actions = NegotiationAction.arel_table
negotiations.join(actions).on(negotiations[:id].eq(actions[:negotiation_id])).
where(actions[:counter].eq(
actions.project(actions[:counter].maximum).
where(actions[:negotiation_id].eq(negotiations[:id]))))