activeadmin

https://github.com/activeadmin/activeadmin

Ruby

The administration framework for Ruby on Rails applications.

ActiveAdmin::BatchAction#initialize

Create a Batch Action

Examples:

  BatchAction.new :flag
=> Will create an action that appears in the action list popover

  BatchAction.new(:flag) { |selection| redirect_to collection_path, notice: "#{selection.length} users flagged" }
=> Will create an action that uses a block to process the request (which receives one paramater of the selected objects)

  BatchAction.new("Perform Long Operation on") { |selection| }
=> You can create batch actions with a title instead of a Symbol

  BatchAction.new(:flag, if: proc{ can? :flag, AdminUser }) { |selection| }
=> You can provide an `:if` proc to choose when the batch action should be displayed

  BatchAction.new :flag, confirm: true
=> You can pass `true` to `:confirm` to use the default confirm message.

  BatchAction.new(:flag, confirm: "Are you sure?") { |selection| }
=> You can pass a custom confirmation message through `:confirm`

  BatchAction.new(:flag, form: {foo: :text, bar: :checkbox}) { |selection, inputs| }
=> You can pass a hash of options to `:form` that will be rendered as form input fields for the user to fill out.

Source | Google | Stack overflow

Edit

git clone git@github.com:activeadmin/activeadmin.git

cd activeadmin

open lib/active_admin/batch_actions/resource_extension.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActiveAdmin--BatchAction-initialize-for-pr


# Commit to git

git add lib/active_admin/batch_actions/resource_extension.rbgit commit -m "better docs for ActiveAdmin::BatchAction#initialize"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActiveAdmin--BatchAction-initialize-for-pr

hub pull-request


# Celebrate!