2013-07-16 44 views
3

我有一個資源稱爲Foobar,我/admin/foobars網頁上我都foobars與選項viewedit列表,delete出現。我只想要editdelete出現。ActiveAdmin - 使資源指數顯示「編輯」和「刪除」而不是「視圖」

應用程序/管理/ foobars.rb

ActiveAdmin.register Foobar do 
    index do 
    # Here I have a bunch of columns for various fields in Foobar 
    # default_actions #=> Uncommenting this line would make view, edit, and delete appear. 
    actions :defaults => false do |foobar| 
     link_to 'Edit', edit_admin_foobar_path(foobar) 
     link_to 'Delete', admin_foobar_path(foobar), :method => :delete, :confirm => "Are you sure" 
    end 
    end 
end 

我的問題是,這隻能說明Delete選項 - Edit只顯示了,當我刪除第二行。我如何讓他們都出現在相同的標題下?

回答

5
ActiveAdmin.register Foobar do 


    index do 
    ... 
    column "" do |resource| 
     links = ''.html_safe 
     links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource), :class => "member_link edit_link" 
     links += link_to I18n.t('active_admin.delete'), resource_path(resource), :method => :delete, :confirm => I18n.t('active_admin.delete_confirmation'), :class => "member_link delete_link" 
     links 
    end 
    end 
end 

編輯

Remove 'Show' link from ActiveAdmin default_actions

+0

是否會禁用顯示頁面?我希望顯示頁面可用,而不是索引操作集中的視圖鏈接。我知道這是一個奇怪的請求,但... – Kvass

+0

我編輯了答案..試試看。 – rmagnum2002

+0

沒有運氣。視圖仍然顯示。 – Kvass

5
ActiveAdmin.register Foobar do 
    actions :all, except: [:view] 
    ... 
end 
0

這裏是我的方式:

index do 
    actions do |resource| 
    (link_to 'link_1", url) + "\t|\t" + 
    (link_to 'link_2", url) 
    end 
end 

=>它產生的觀點:LINK_1 |鏈接2

相關問題