Sha256: cd6fcdfbcaf3f2f7b975e748781600ed89f166a60974b0ca67061f9ef5105bf6

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

require_dependency "front_end_builds/application_controller"

module FrontEndBuilds
  class PubkeysController < ApplicationController
    def index
      keys = FrontEndBuilds::Pubkey.order(:name)
      respond_with_json(pubkeys: keys.map(&:serialize))
    end

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

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

    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

    private

    def pubkey_create_params_rails_3
      params[:pubkey].slice(:name, :pubkey)
    end

    def pubkey_create_params_rails_4
      params.require(:pubkey).permit(
        :name,
        :pubkey
      )
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
front_end_builds-0.2.1 app/controllers/front_end_builds/pubkeys_controller.rb
front_end_builds-0.2.0 app/controllers/front_end_builds/pubkeys_controller.rb
front_end_builds-0.1.3 app/controllers/front_end_builds/pubkeys_controller.rb
front_end_builds-0.1.2 app/controllers/front_end_builds/pubkeys_controller.rb
front_end_builds-0.1.1 app/controllers/front_end_builds/pubkeys_controller.rb
front_end_builds-0.1.0 app/controllers/front_end_builds/pubkeys_controller.rb