summaryrefslogtreecommitdiff
path: root/app/controllers/deploy_keys_controller.rb
blob: 36e42789e1134363070a239963ee5b5270c2ccc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class DeployKeysController < ApplicationController
  respond_to :js, :html
  layout "project"
  before_filter :project

  # Authorize
  before_filter :add_project_abilities
  before_filter :authorize_admin_project!

  def project
    @project ||= Project.find_by_code(params[:project_id])
  end

  def index
    @keys = @project.deploy_keys.all
  end

  def show
    @key = @project.deploy_keys.find(params[:id])
  end

  def new
    @key = @project.deploy_keys.new

    respond_with(@key)
  end

  def create
    @key = @project.deploy_keys.new(params[:key])
    @key.save

    respond_with(@key)
  end

  def destroy
    @key = @project.deploy_keys.find(params[:id])
    @key.destroy

    respond_to do |format|
      format.html { redirect_to project_deploy_keys_url }
      format.js { render :nothing => true }
    end
  end
end