@H_502_1@我正在使用ActiveAdmin和Formtastic.
我有一张发票单,有一个出货单的下拉菜单.
@H_502_4@form do |f| f.inputs "Shipment Details" do f.input :shipment_id,:label => "Shipment",:as => :select,:collection => Shipment.find(invoiceless_shipments,:order => "file_number",:select => "id,file_number").map{|v| [v.file_number,v.id] } f.input :issued_at,:label => "Date",:as => :datepicker ... more fields ... end如果表单是编辑表单,我不想显示出货下拉菜单.因此,如果表单是编辑表单,则不会更改.
我正在考虑做一些类似的事情
@H_502_4@if params[:action] != 'edit' f.input :shipment_id,:as => :select... end但我收到DSL错误.
解决方法
尝试
@H_502_4@form do |f|
f.inputs "Shipment Details" do
if f.object.new_record?
f.input :shipment_id,:as => :select...
end
...
end
end
问题(部分)在这里提到:Accessing object of form in formtastic