Class: SpreeCmCommissioner::GuestCardsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/spree_cm_commissioner/guest_cards_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/spree_cm_commissioner/guest_cards_controller.rb', line 5

def show
  guest = SpreeCmCommissioner::Guest
          .includes(line_item: { variant: :guest_card_classes })
          .find_by!(token: params[:id])

  # Cache the response
  cache_key = "#{guest.id}-#{guest.updated_at}-#{guest.line_item.variant.guest_card_classes.first!.updated_at}"

  locals = Rails.cache.fetch(cache_key, expires_in: 12.hours) do
    guest_card_locals(guest)
  end

  render(
    template: 'spree_cm_commissioner/guest_cards/show',
    locals: locals
  )
end