Class: Admin::BulkActionsController
- Inherits:
-
AdminController
- Object
- ApplicationController
- AdminController
- Admin::BulkActionsController
- Defined in:
- app/controllers/admin/bulk_actions_controller.rb
Instance Method Summary collapse
-
#create ⇒ BulkAction
POST /bulk_actions POST /bulk_actions.json.
-
#destroy ⇒ void
DELETE /bulk_actions/1 DELETE /bulk_actions/1.json.
-
#edit ⇒ BulkAction
GET /bulk_actions/1/edit.
-
#index ⇒ Array<BulkAction>
GET /bulk_actions GET /bulk_actions.json.
-
#new ⇒ BulkAction
GET /bulk_actions/new.
-
#revert ⇒ void
Reverts a bulk action.
-
#run ⇒ void
Runs a bulk action.
-
#show ⇒ BulkAction
GET /bulk_actions/1 GET /bulk_actions/1.json.
-
#update ⇒ BulkAction
PATCH/PUT /bulk_actions/1 PATCH/PUT /bulk_actions/1.json.
Instance Method Details
#create ⇒ BulkAction
POST /bulk_actions POST /bulk_actions.json
Creates a new bulk action.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 50 def create @bulk_action = BulkAction.new(bulk_action_params) respond_to do |format| if @bulk_action.save format.html do redirect_to admin_bulk_action_path(@bulk_action), notice: "Bulk action was successfully created." end format.json { render :show, status: :created, location: @bulk_action } else format.html { render :new } format.json { render json: @bulk_action.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ void
This method returns an undefined value.
DELETE /bulk_actions/1 DELETE /bulk_actions/1.json
Deletes a bulk action.
90 91 92 93 94 95 96 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 90 def destroy @bulk_action.destroy respond_to do |format| format.html { redirect_to admin_bulk_actions_url, notice: "Bulk action was successfully destroyed." } format.json { head :no_content } end end |
#edit ⇒ BulkAction
GET /bulk_actions/1/edit
Prepares a bulk action for editing.
42 43 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 42 def edit end |
#index ⇒ Array<BulkAction>
GET /bulk_actions GET /bulk_actions.json
Lists all bulk actions, paginated.
16 17 18 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 16 def index @pagy, @bulk_actions = pagy(BulkAction.all.order(created_at: :desc), items: 20) end |
#new ⇒ BulkAction
GET /bulk_actions/new
Initializes a new bulk action with a given scope.
34 35 36 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 34 def new @bulk_action = BulkAction.new(scope: params[:scope]) end |
#revert ⇒ void
This method returns an undefined value.
Reverts a bulk action.
108 109 110 111 112 113 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 108 def revert @bulk_action.revert! @bulk_action.state_machine.transition_to!(:queued) redirect_to admin_bulk_action_url(@bulk_action), notice: "Revert bulk action is running. Check back soon for results." end |
#run ⇒ void
This method returns an undefined value.
Runs a bulk action.
100 101 102 103 104 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 100 def run @bulk_action.run! # @bulk_action.state_machine.transition_to!(:queued) redirect_to admin_bulk_action_url(@bulk_action), notice: "Bulk action is running. Check back soon for results." end |
#show ⇒ BulkAction
GET /bulk_actions/1 GET /bulk_actions/1.json
Shows a specific bulk action and its associated documents.
25 26 27 28 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 25 def show @pagy, @documents = pagy(@bulk_action.documents, items: 30) @bulk_action.check_run_state end |
#update ⇒ BulkAction
PATCH/PUT /bulk_actions/1 PATCH/PUT /bulk_actions/1.json
Updates an existing bulk action.
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/admin/bulk_actions_controller.rb', line 71 def update respond_to do |format| if @bulk_action.update(bulk_action_params) format.html do redirect_to admin_bulk_action_path(@bulk_action), notice: "Bulk action was successfully updated." end format.json { render :show, status: :ok, location: @bulk_action } else format.html { render :edit } format.json { render json: @bulk_action.errors, status: :unprocessable_entity } end end end |