我需要一种表格,以便能够基于另一个显示一个选择。
我有以下数据库架构:
order <-->> line_items <<-->> product <-->> campaign <br>
order <<--> customer
我有以下表格:
form do |f|
f.inputs I18n.t("New Order") do
f.input :customer, :collection => Customer.where(:id => order.customer_id).map{ |customer| [customer. FirstName + ' ' + customer.LastName, customer.id] }
end
f.has_many :line_items do |app_f|
app_f.input :quantity
#some code that show campaign to filter :product_id
app_f.input :product_id, :as => :select, :collection => Product.all.map{ |product| [product.name, product.id] }
if app_f.object.id
app_f.input :_destroy, :as => :boolean, :label => I18n.t("Delete")
end
app_f.form_buffers.last # to avoid bug with nil possibly being returned from the above
end
end
f.actions
end
我需要在这里显示一个活动选择器,该选择器过滤产品选择器以根据嵌套形式的活动显示产品。(类似于拥有产品类别过滤器)
知道该怎么做吗?
谢谢,