Active admin and user method

This is my Active Admin user page.

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 the "import projects" button, I want to generate a rake task using a controller. But I can not access the method.

What could be the problem or what am I doing wrong?

thank

+5
source share
1 answer

Ok, found this 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 a button and runs the 'updateprojects' method

+9
source

All Articles