This is my custom page in Active Admin
ActiveAdmin.register_page "Settings" do
  action_item do
     link_to('Import projects', 'settings/importprojects')
  end
  content do
    para "Text"
  end
  controller do
    def importprojects
      system "rake dataspider:import_projects_ninja"
      para "OK"
    end
  end
end
What I'm trying to do is, when I click on the button 'import projects', I want to preform a rake task with is in the controller. But I can't access the method.
What could be the problem or what I'm a doing wrong?
Thanks
Okay, found it and here is the solution:
  sidebar :actions do
    button_to "Update projects", "/admin/projects/updateprojects", :method => :post, :confirm => "Are you sure?"
  end
  collection_action :updateprojects, :method => :post do
    system "rake dataspider:import_projects_ninja"
    redirect_to admin_projects_path, :notice => "Syncing..."  
  end
I created an button and it runs the method 'updateprojects'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With