4

I have this:

ActiveAdmin.register User do
  index do
    column :email
        column :name
    column :role
    column "Last Sign In", :last_sign_in_at
        column :account
        column "Units" do |user|
            user.units.count.to_s
        end
    default_actions
end

The default_actions method should create the show, edit, and delete links. It shows them but the delete link is just a link to the show action:

admin/users/1

Specifications said it should create a delete link.

Dont know why it did that. So I tried an alternative:

 column "Delete" do |user|
   link_to "Delete", destroy_admin_user_path(user)
 end

I get this error:

undefined method `destroy_admin_user_path' for <div class="index_as_table"></div>:ActiveAdmin::Views::IndexAsTable

I even tried adding this in routes:

match "/admin/users/:id/destroy(.:format) " => "admin/users#destroy"

Still got same error.

I included this in application.html.haml:

        = javascript_include_tag :all

Still same problems as above.

Thanks for response

4

3 に答える 3

11

This is a bit late but the real real reason your link wasn't working is because you didn't put the :method in your link and instead used "destroy_admin_user_path".

Try this instead:

link_to "Delete", admin_user_path(user), :method => :delete, :data => {:confirm => "Are you sure?"}

This is what works for me, with ActiveAdmin.

于 2012-11-04T07:43:16.890 に答える
4

I had this problem when I updated the active_admin gem, so I fixed it regenerating the active_admin assets and now the destroy action works fine.

rails generate active_admin:assets
于 2012-06-02T13:34:57.490 に答える
3

Did you check to see if the full rails.js is added to the javascript? Use firebug to inspect the link and see if it has the data-method attribute. Also inspect the HTTP headers and see if the request is made with DELETE.

If the request is not made using "DELETE" than you have a problem with your javascripts. Check rails.js for integrity and jquery integration. Additionally check your assets.

Could your provide more details about your rails version? Javascripts included in HTML source?

Try another thing, go to assets/javascripts/application.js and add

//= require jquery

to the top if you are running 3.1

于 2011-09-13T05:50:36.693 に答える