Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch Action greyed out and not working #1462

Closed
ashleywysocki opened this issue Jul 3, 2012 · 17 comments
Closed

Batch Action greyed out and not working #1462

ashleywysocki opened this issue Jul 3, 2012 · 17 comments

Comments

@ashleywysocki
Copy link

I'm using the latest version of Active Admin (gemfile leads to gem "activeadmin", :git => "git://github.com/gregbell/active_admin.git") and in my Active Admin site, the Batch Action option is showing. However it's greyed out and it's not set to false in the config file. I tried to add a batch again to my mode programs:

batch_action :save do |selection|
  Program.find(selection).each do |program|
    program.save
  end
end

But that's not showing up either and I'm not sure if it's the right syntax (the :hot confuses me). Does anyone know how to fix this?

@smikkelsen
Copy link

I am not able to get the batch actions working at all. I have done a bundle install (gem 'activeadmin') in gemfile, so it should be pulling master. The version shows that I DO have 0.4.4 but I am missing some of the files such as batch_actions.rb. I have deleted, and re-installed the gem, i've done gem update, and plain old bundle install multiple times, but it doesn't appear to be grabbing the master. Any ideas on what I can do to fix this?

@pcreux
Copy link
Contributor

pcreux commented Jul 4, 2012

@smikkelsen ActiveAdmin 0.4.4 (the latest gem) is definitely not pulling from master. Update your gemfile to use ActiveAdmin from master if you want batch actions.

@pcreux
Copy link
Contributor

pcreux commented Jul 4, 2012

@ashleywysocki Could you force the option to "true" in the initializer?

@smikkelsen
Copy link

@pcreux Thanks a lot for your reply. I still cannot get it working. I updated the gemfile to this:
gem 'activeadmin', :branch => 'master'
(previously I had this:)
gem 'activeadmin'

I assumed that both would pull from master.

"ActiveAdmin 0.4.4 (the latest gem) is definitely not pulling from master."
I'm not sure what you meant by this. Is 0.4.4 not the current version on master branch?

Thanks again for your help!

@jpmckinney
Copy link
Contributor

To get the latest ActiveAdmin code use this line in your Gemfile:

gem 'activeadmin', :git => 'git://github.com/gregbell/active_admin.git'

@ghost
Copy link

ghost commented Aug 5, 2012

I have the same issue. The checkbox appear but it does nothing.
Is it controlled by javascript or something?

@marclennox
Copy link

+1 same issue, I have the batch action drop down button greyed out... Confirmed I have 0.4.4 latest.

@jpmckinney
Copy link
Contributor

0.4.4 is not the latest. What's on GitHub is the latest. See my earlier comment for how to get the latest code from GitHub.

For those who already have that line in their Gemfile, you can run bundle update activeadmin to grab the latest code.

@bishma-stornelli
Copy link

I have a resource with this:

ActivAdmin.register Assignment do
    config.batch_actions = true

    batch_action :destroy, false

    batch_action :approve do |selection|
        ....
    end

    index do
        selectable_column
        ....
    end
end

It's showing the selectable column and it's showing the batch action button. It's disabled but when I select at least one row in the selectable column it becomes active.

When I press the button, there's nothing in it. If a remove the batch_action :destroy, false line then I see the destroy option but the approve option is not displayed.

I even put the line puts "The batch actions are: #{config.batch_actions.inspect} and it's showing both actions. I changed the html to data-action="approve" and sent the action and it worked fine but the approve option just doesn't appear.

It may be a problem when rendering the view? Please help, I need this ASAP.

My configuration:

rails 3.2.6
ruby 1.9.3
activeadmin 0.5.0

@bishma-stornelli
Copy link

I found the problem in my case.

I had:

batch_action :approve, :if => true do

end

but option[:if] must be a proc. It should be good if it raise an error instead of ignoring this.

@DSushil20
Copy link

Had same problem, found as java script issue; solved with,

rails generate active_admin:assets

and this worked !!
#309

@ttseng
Copy link

ttseng commented Jan 16, 2013

I am having the same issue where the batch action is greyed out for all my resources.

In active_admin.rb, I have:

  config.batch_actions = true

This is my index file for my resource Image:

ActiveAdmin.register Image do
index do
    column :id
    column :project_id
    column :step_id
    column :file
    column :caption
    column :created_at
    column :updated_at
    default_actions
end  
actions :all
 end

I am using the latest version of activeadmin (0.5.1) and also ran "rails generate active_admin:assets"

Please help!

@seanlinsley
Copy link
Contributor

@ttseng, you need to include selectable_column like so:

index do
  selectable_column
  column :id
  # ...

@ttseng
Copy link

ttseng commented Jan 18, 2013

great this works for me. thanks!

@ttseng
Copy link

ttseng commented Jan 18, 2013

hm, actually, when I try to implement my own batch action, I am getting the following error:

Missing template admin/images/batch_action

@seanlinsley
Copy link
Contributor

@ttseng, as always, you should first refer to the docs for help. That example in the docs will actually cause the exact same error you ran into.

The problem with the example is it doesn't explicitly tell the controller what to render after the batch action is finished. You need to do something along these lines:

batch_action :stuff do |ids|
  # use those IDs to do stuff here
  redirect_to collection_path, :notice => "We did stuff!"
end

If you don't tell the controller what to do, it will implicitly look for a view template to render based on the current controller action. Hence the error, "Missing template admin/images/batch_action"

@seanlinsley
Copy link
Contributor

I'm currently working on cleaning up the documentation, and at the very least I've fixed the problem I mentioned earlier. Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants