Class: FrontEndBuilds::PubkeysController

Inherits:
ApplicationController show all
Defined in:
app/controllers/front_end_builds/pubkeys_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#error!, #respond_with_json

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/front_end_builds/pubkeys_controller.rb', line 10

def create
  pubkey = FrontEndBuilds::Pubkey.new(pubkey_create_params)

  if pubkey.save
    respond_with_json(
      { pubkey: pubkey.serialize },
      location: nil
    )
  else
    error!(pubkey.errors)
  end
end

#destroyObject



23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/front_end_builds/pubkeys_controller.rb', line 23

def destroy
  pubkey = FrontEndBuilds::Pubkey.find(params[:id])

  if pubkey.destroy
    respond_with_json(
      { pubkey: { id: pubkey.id } },
      location: nil
    )
  else
    error!(pubkey.errors)
  end
end

#indexObject



5
6
7
8
# File 'app/controllers/front_end_builds/pubkeys_controller.rb', line 5

def index
  keys = FrontEndBuilds::Pubkey.order(:name)
  respond_with_json(pubkeys: keys.map(&:serialize))
end