Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activeadmin disable batch action for single row

admin/user.rb

  index row_class: ->user { 'active' if user.deleted_at? } do
    selectable_column
    id_column
    column :email
    column :name
    actions
  end

  User.all.each do |user|
    if user.deleted_at?
      config.batch_actions = false
    end
  end

At the moment i have batch actions for all the users. However, I don't want batch action select box present for soft deleted users. I tried to loop through all the users and made batch_actions false for deleted_at users. But that doesn't seems to be working. Is it even possible?

like image 881
Ray Avatar asked Nov 26 '25 13:11

Ray


1 Answers

You can use the source for selectable_column to do it:

column resource_selection_toggle_cell, class: 'col-selectable', sortable: false do |resource|
  if resource.can_be_selected?
    resource_selection_cell resource
  end
end
like image 52
David Parker Avatar answered Nov 28 '25 01:11

David Parker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!