Class: Staff::EndpointsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- Staff::EndpointsController
- Defined in:
- app/controllers/staff/endpoints_controller.rb
Overview
Staff-only CRUD functions for Endpoints
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
[View source]
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/staff/endpoints_controller.rb', line 22 def create self.endpoint = Endpoint.create(endpoint_params) if endpoint logger.info "Created #{endpoint}" redirect_to [:staff, endpoint] else logger.warn "Unable to create '#{endpoint}' due to '#{endpoint.error_sentence}'" render :new end end |
#destroy ⇒ Object
[View source]
43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/staff/endpoints_controller.rb', line 43 def destroy endpoint.destroy msg = "Deleted #{endpoint}" redirect_to staff_endpoints_path, notice: msg rescue ActiveRecord::DeleteRestrictionError => e msg = "Unable to delete '#{endpoint}' due to '#{e}'" logger.error msg redirect_to staff_endpoint_path(endpoint), alert: msg end |
#edit ⇒ Object
[View source]
19 20 |
# File 'app/controllers/staff/endpoints_controller.rb', line 19 def edit end |
#index ⇒ Object
[View source]
8 9 10 |
# File 'app/controllers/staff/endpoints_controller.rb', line 8 def index self.endpoints = Endpoint.sorted end |
#new ⇒ Object
[View source]
12 13 14 |
# File 'app/controllers/staff/endpoints_controller.rb', line 12 def new self.endpoint = Endpoint.new end |
#show ⇒ Object
[View source]
16 17 |
# File 'app/controllers/staff/endpoints_controller.rb', line 16 def show end |
#update ⇒ Object
[View source]
34 35 36 37 38 39 40 41 |
# File 'app/controllers/staff/endpoints_controller.rb', line 34 def update if endpoint.update(endpoint_params) redirect_to staff_endpoint_path(endpoint), notice: 'Endpoint was successfully updated' else logger.warn "Unable to update #{endpoint}: #{endpoint.error_sentence}" render :edit end end |