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
28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/plug/features_controller.rb', line 28 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
48 49 50 51 |
# File 'app/controllers/plug/features_controller.rb', line 48 def destroy @feature.destroy redirect_to features_url, notice: 'Feature was successfully destroyed.' end |
#edit ⇒ Object
GET /features/1/edit
25 |
# File 'app/controllers/plug/features_controller.rb', line 25 def edit; end |
#index ⇒ Object
GET /features
12 13 14 |
# File 'app/controllers/plug/features_controller.rb', line 12 def index @features = Feature.all end |
#new ⇒ Object
GET /features/new
20 21 22 |
# File 'app/controllers/plug/features_controller.rb', line 20 def new @feature = Feature.new end |
#task_execution ⇒ Object
POST /task TODO: Move this to a separate controller e.g. ‘tasks_controller.rb`
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/plug/features_controller.rb', line 55 def task_execution begin require 'rake' Rails.application.load_tasks ::Rake::Task[params[:task]].execute 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
39 40 41 42 43 44 45 |
# File 'app/controllers/plug/features_controller.rb', line 39 def update if @feature.update_attributes(feature_params) redirect_to features_path, notice: 'Feature was successfully updated.' else render :edit end end |