Class: WebHooksController

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

Instance Method Summary collapse

Instance Method Details

#createObject


13
14
15
16
17
18
19
20
# File 'app/controllers/web_hooks_controller.rb', line 13

def create
  @web_hook = @github_repository.web_hooks.build(web_hook_params)
  if @web_hook.save
    redirect_to github_repository_web_hooks_path(@github_repository.owner_name, @github_repository.project_name), notice: 'Web hook created'
  else
    render :new
  end
end

#destroyObject


41
42
43
44
45
# File 'app/controllers/web_hooks_controller.rb', line 41

def destroy
  @web_hook = @github_repository.web_hooks.find(params[:id])
  @web_hook.destroy
  redirect_to github_repository_web_hooks_path(@github_repository.owner_name, @github_repository.project_name), notice: 'Web hook deleted'
end

#editObject


28
29
30
# File 'app/controllers/web_hooks_controller.rb', line 28

def edit
  @web_hook = @github_repository.web_hooks.find(params[:id])
end

#indexObject


5
6
7
# File 'app/controllers/web_hooks_controller.rb', line 5

def index
  @web_hooks = @github_repository.web_hooks.paginate(page: params[:page])
end

#newObject


9
10
11
# File 'app/controllers/web_hooks_controller.rb', line 9

def new
  @web_hook = @github_repository.web_hooks.build
end

#testObject


22
23
24
25
26
# File 'app/controllers/web_hooks_controller.rb', line 22

def test
  @web_hook = @github_repository.web_hooks.find(params[:id])
  @web_hook.send_test_payload
  redirect_to github_repository_web_hooks_path(@github_repository.owner_name, @github_repository.project_name), notice: 'Web hook test sent'
end

#updateObject


32
33
34
35
36
37
38
39
# File 'app/controllers/web_hooks_controller.rb', line 32

def update
  @web_hook = @github_repository.web_hooks.find(params[:id])
  if @web_hook.update_attributes(web_hook_params)
    redirect_to github_repository_web_hooks_path(@github_repository.owner_name, @github_repository.project_name), notice: 'Web hook updated'
  else
    render :edit
  end
end