2015-07-20 31 views
-1

我很新的主動管理和使用下面的表格主動管理軌操作按鈕

active_admin_form_for resource, :url => account_setup_admin_customer_path(resource), :method => :post, :html => {:class => "new_meeting_search", :id => "meeting_search"} do |f| 
    f.inputs "Customer Details" do 
    h2 "Customer Name: #{resource.first_name} #{resource.last_name}" 
    h2 "Company: #{resource.company_name}" 
    h2 "Email: #{resource.email}" 
    f.input :bill_to 
    f.input :ship_to 
    f.input :primary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]] 
    f.input :secondary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]] 
    f.input :ips_primary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]] 
    f.input :ips_secondary_dc, :as => :select, :collection => [["CI - Chambersburg, PA", "CI - Chambersburg, PA"], ["DD - Fort Wayne, IN", "DD - Fort Wayne, IN"], ["EE - Roseburg, OR", "EE - Roseburg, OR"], ["NV - La Vergne, TN", "NV - La Vergne, TN"]] 
    f.input :ipi_account_number 
    f.input :ipage_username 
    f.input :ipage_password 
    f.input :status, :as => :select, :collection => [["Approved", "Approved"], ["Denied", "Denied"]] 
    f.input :status_comment 
    end 
    f.actions 
end 

相反狀態下拉菜單中,我想單獨行動按鈕「批准」,「拒絕」,「取消」。我不確定如何在活動窗體中添加自定義按鈕。

+0

請讓我知道如果我nswer是有幫助 –

+0

嗨.. .Sorry Andrey ....我沒有登錄後發佈我的問題...設法讓它工作...感謝您的幫助...您的方式更好... ... – OmK

回答

0

爲此,您將需要使用member_action

首先,在模型中創建一個公共方法:

model MyModel 
    #... 
    def approve 
    #... any logic here, for example: 
    update(status: 'Approved') 
    end 
end 

然後,在AA頁面,你會做:

action_item only: [:edit] do # or any page, where you need this button 
    link_to('Approve', the_path_to_aprove(resource), method: :post 
    end 


    member_action :approve, method: :post do 
     if resource.approve 
     redirect_to somewhere_path, notice: "This have been approved!" 
     else 
     redirect_to somewhere_else_path, alert: "Sorry, not all requirements were met for approving" 
     end 
    end 
    end 
0

你可以放3個鏈接來模擬。更多的細節可以參考AA的表格定製document