Class: Plug::FeaturesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Plug::FeaturesController
- Defined in:
- app/controllers/plug/features_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /features.
-
#destroy ⇒ Object
DELETE /features/1.
-
#edit ⇒ Object
GET /features/1/edit.
-
#index ⇒ Object
GET /features.
-
#new ⇒ Object
GET /features/new.
-
#task_execution ⇒ Object
POST /task TODO: Move this to a separate controller e.g.
-
#update ⇒ Object
PATCH/PUT /features/1.
Instance Method Details
#create ⇒ Object
POST /features
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/plug/features_controller.rb', line 26 def create @feature = Feature.new(feature_params) if @feature.save redirect_to features_path, notice: 'Feature was successfully created.' else render :new end end |
#destroy ⇒ Object
DELETE /features/1
46 47 48 49 |
# File 'app/controllers/plug/features_controller.rb', line 46 def destroy @feature.destroy redirect_to features_url, notice: 'Feature was successfully destroyed.' end |
#edit ⇒ Object
GET /features/1/edit
23 |
# File 'app/controllers/plug/features_controller.rb', line 23 def edit; end |
#index ⇒ Object
GET /features
10 11 12 |
# File 'app/controllers/plug/features_controller.rb', line 10 def index @features = Feature.all end |
#new ⇒ Object
GET /features/new
18 19 20 |
# File 'app/controllers/plug/features_controller.rb', line 18 def new @feature = Feature.new end |
#task_execution ⇒ Object
POST /task TODO: Move this to a separate controller e.g. ‘tasks_controller.rb`
53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/plug/features_controller.rb', line 53 def task_execution begin Plug::TaskExecutionService.new(name: params[:task]).call rescue StandardError => e flash[:alert] = e. else flash[:notice] = "Task: #{params[:task]} has completed" end redirect_to root_path end |
#update ⇒ Object
PATCH/PUT /features/1
37 38 39 40 41 42 43 |
# File 'app/controllers/plug/features_controller.rb', line 37 def update if @feature.update(feature_params) redirect_to features_path, notice: 'Feature was successfully updated.' else render :edit end end |