Class: Webhooks::EndpointsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/webhooks/endpoints_controller.rb', line 19

def create
  @endpoint = Webhooks::Endpoint.new(endpoint_params)

  if @endpoint.save
    redirect_to endpoint_path(@endpoint), flash: {
      success: 'Successfully created new webhook endpoint.',
    }
  else
    render :new
  end
end

#destroyObject



47
48
49
50
51
52
53
54
55
56
57
# File 'app/controllers/webhooks/endpoints_controller.rb', line 47

def destroy
  @endpoint = Webhooks::Endpoint.find(params[:id])

  if @endpoint.destroy
    redirect_to endpoints_path, flash: {
      success: 'Deleted endpoint.',
    }
  else
    redirect_back fallback_location: @endpoint
  end
end

#editObject



31
32
33
# File 'app/controllers/webhooks/endpoints_controller.rb', line 31

def edit
  @endpoint = Webhooks::Endpoint.find(params[:id])
end

#indexObject



7
8
9
# File 'app/controllers/webhooks/endpoints_controller.rb', line 7

def index
  @endpoints = Webhooks::Endpoint.order(created_at: :asc)
end

#newObject



15
16
17
# File 'app/controllers/webhooks/endpoints_controller.rb', line 15

def new
  @endpoint = Webhooks::Endpoint.new
end

#showObject



11
12
13
# File 'app/controllers/webhooks/endpoints_controller.rb', line 11

def show
  @endpoint = Webhooks::Endpoint.find(params[:id])
end

#updateObject



35
36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/webhooks/endpoints_controller.rb', line 35

def update
  @endpoint = Webhooks::Endpoint.find(params[:id])

  if @endpoint.update(endpoint_params)
    redirect_to edit_endpoint_path(@endpoint), flash: {
      success: 'Changes saved.',
    }
  else
    render :edit
  end
end