简体   繁体   中英

How to custom actions method helper in active admin

when i define

  index do
    column :id, :sortable => :id
    column :title
    column :avatar do |post|
      div style: "text-align:center;" do 
        image_tag post.avatar_url(:thumb), :class => "img-responsive"
      end 
    end
    column :published
    actions
  end 

"actions" general 3 links (view, edit, and delete) I want to add target="_parent" for 3 links above.

example:

<a class="edit_link member_link" href="/admin/places/5/edit?locale=en">Edit</a>

to

<a class="edit_link member_link" href="/admin/places/5/edit?locale=en" target="_parent">Edit</a>

How to do this?

To setup links to View, Edit and Delete a resource, use the actions method:

index do
  selectable_column
  column :title
  actions
end

You can also append custom links to the default links:

index do
  selectable_column
  column :title
  actions do |post|
    link_to "Preview", admin_preview_post_path(post), class: "member_link"
  end
end

Or forego the default links entirely:

index do
  column :title
  actions defaults: false do |post|
    link_to "View", admin_post_path(post)
  end
end

In case you prefer to list actions links in a dropdown menu:

index do
  selectable_column
  column :title
  actions dropdown: true do |post|
    item "Preview", admin_preview_post_path(post)
  end
end

Reference: http://activeadmin.info/docs/3-index-pages/index-as-table.html#defining-columns

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM