63 lines
1.4 KiB
Ruby
63 lines
1.4 KiB
Ruby
class OperationsController < ApplicationController
|
|
before_action :set_filter
|
|
before_action :set_operation, only: [:show, :edit, :update, :destroy]
|
|
|
|
# GET /operations
|
|
def index
|
|
@operations = @filter.operations.all
|
|
end
|
|
|
|
# GET /operations/1
|
|
def show
|
|
end
|
|
|
|
# GET /operations/new
|
|
def new
|
|
@operation = @filter.operations.new
|
|
end
|
|
|
|
# GET /operations/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /operations
|
|
def create
|
|
@operation = @filter.operations.new(operation_params)
|
|
|
|
if @operation.save
|
|
redirect_to @filter, notice: 'Operation was successfully created.'
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /operations/1
|
|
def update
|
|
if @operation.update(operation_params)
|
|
redirect_to @filter, notice: 'Operation was successfully updated.'
|
|
else
|
|
render :edit
|
|
end
|
|
end
|
|
|
|
# DELETE /operations/1
|
|
def destroy
|
|
@operation.destroy
|
|
redirect_to @filter, notice: 'Operation was successfully destroyed.'
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between operations.
|
|
def set_filter
|
|
@filter = Filter.find(params[:filter_id])
|
|
end
|
|
def set_operation
|
|
@operation = @filter.operations.find(params[:id])
|
|
end
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
def operation_params
|
|
params.require(:operation).permit(:enabled, :class_name, :argument)
|
|
end
|
|
end
|