Class: Crest::CardsController

Inherits:
ActionController::Base
  • Object
show all
Defined in:
lib/crest/cards_controller.rb

Overview

Hands out the contact card. It descends from ActionController::Base rather than from the host's ApplicationController on purpose: the card is public by definition, and an inherited before_action :authenticate would refuse the one request this exists to answer.

Constant Summary collapse

TYPE =

What a phone has to be told the body is before it offers to save it.

'text/vcard; charset=utf-8'

Instance Method Summary collapse

Instance Method Details

#showvoid

This method returns an undefined value.

Answers the card, named after the path it was drawn at and cached until the card changes.



11
12
13
14
15
16
17
# File 'lib/crest/cards_controller.rb', line 11

def show
  card = Crest.card.to_s

  if stale?(etag: card, public: true)
    send_data card, type: TYPE, disposition: 'inline', filename: File.basename(request.path)
  end
end