Module: Capybara::ActiveAdmin::Actions::Table

Included in:
Capybara::ActiveAdmin::Actions
Defined in:
lib/capybara/active_admin/actions/table.rb

Instance Method Summary collapse

Instance Method Details

#select_table_row(id: nil, index: nil) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/capybara/active_admin/actions/table.rb', line 7

def select_table_row(id: nil, index: nil)
  raise ArgumentError, "can't use both :id and :index" if id && index
  raise ArgumentError, 'must provide :id or :index' if id.nil? && index.nil?

  if id
    find("input#batch_action_item_#{id}").click
    return
  end

  selector = %(input[id^="batch_action_item_"])
  find_all(selector, minimum: index + 1)[index].click
end