2016-04-27 50 views
0

當我定義我如何主動管理

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個環節(查看,編輯和刪除) 自定義操作方法幫手要添加目標=「_父」 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> 

如何做到這一點?

回答

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

+0

TKS,我想在鏈接到新的對象添加'目標='_ parent''。這個怎麼做? –