最後に、client_id をパーシャルに渡すテキスト フィールドが必要です。textfield の値が更新されると、shipping_products パーシャルが動的に変更されるように、これを非同期で行いたいと思います。これを行う最善の方法は何ですか?
index.html.erb で
<!-- Text Field Here-->
<div id="available_products">
<%= render "shipment_products" %>
</div>
_shipment_products.html.erb 内
<div id="shipment_products_container">
<h3>Assign Products to Ship<\h3>
<ul class="shipment_products" id="shipment_products">
<% Product.by_client(client_id).each do |product|%> <!-- TextField value passed here -->
<%= content_tag_for :li, product, :value => product.id do %>
<%= hidden_field_tag("shipment[product_ids][]", product.id) %>
<%= product.product_name %>
<% end %>
<% end %>
<\ul>
</div>
モデル関係:
Models and Relationships
Shipment has_many :products :through => :shipment_products
Product has_many :shipments :through => :shipment_products
ShipmentProducts belongs_to :shipment, belongs_to :product
Product belongs_to :client
Client has_many :products
これは、私が最終的に望むものと似ています。