2015-07-20 55 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