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

时间:2016-04-27 07:42:15

标签: ruby-on-rails ruby-on-rails-4 rubygems activeadmin

当我定义

  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 

"动作"一般3个链接(查看,编辑和删除)  我想添加target =" _parent"上面有3个链接。

示例:

<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>

怎么做?

1 个答案:

答案 0 :(得分:0)

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

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