Module: WebHooks::HookActions

Extended by:
ActiveSupport::Concern
Includes:
HookExecutionNotice
Included in:
Admin::HooksController, Projects::HooksController
Defined in:
app/controllers/concerns/web_hooks/hook_actions.rb

Instance Method Summary collapse

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 20

def create
  self.hook = relation.new(hook_params)
  hook.save

  if hook.valid?
    flash[:notice] = _('Webhook was created')
  else
    self.hooks = relation.select(&:persisted?)
    flash[:alert] = hook.errors.full_messages.to_sentence.html_safe
  end

  redirect_to action: :index
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 43

def destroy
  destroy_hook(hook)

  redirect_to action: :index, status: :found
end

#editObject



49
50
51
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 49

def edit
  redirect_to(action: :index) unless hook
end

#indexObject



15
16
17
18
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 15

def index
  self.hooks = relation.select(&:persisted?)
  self.hook = relation.new
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/concerns/web_hooks/hook_actions.rb', line 34

def update
  if hook.update(hook_params)
    flash[:notice] = _('Webhook was updated')
    redirect_to action: :edit
  else
    render 'edit'
  end
end