如何在活动管理员中自定义操作方法助手

How to custom actions method helper in active admin

当我定义

  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" 一般 3 个链接(查看、编辑和删除) 我想为上面的 3 个链接添加 target="_parent"。

示例:

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

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

如何操作?

要设置查看、编辑和删除资源的链接,请使用操作方法:

index do
  selectable_column
  column :title
  actions
end

您还可以将自定义链接附加到默认链接:

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

或者完全放弃默认链接:

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

如果您更喜欢在下拉菜单中列出操作链接:

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

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