Ruby on rails 如何在RubyonRails中显示来自不同模型的选定下拉式内部属性

Ruby on rails 如何在RubyonRails中显示来自不同模型的选定下拉式内部属性,ruby-on-rails,ruby,Ruby On Rails,Ruby,我有两种不同的模型store\U item和indent。关系在indent-中有很多:store\U item和In store\U item-属于:indent。 在缩进表单上,我已经使用了下拉列表,即保存缩进时的store\u item\u id。我如何显示store\u item内部属性以及所选属性,即单价、批次号、数量。就好像现在显示所有store\u items一样 缩进/新缩进 预期产出: Item Name:Marker Pens Store Name:Kirti Store B

我有两种不同的模型store\U item和indent。关系在indent-
中有很多:store\U item
和In store\U item-
属于:indent
。 在缩进表单上,我已经使用了下拉列表,即保存缩进时的store\u item\u id。我如何显示store\u item内部属性以及所选属性,即单价、批次号、数量。就好像现在显示所有store\u items一样

缩进/新缩进 预期产出:

Item Name:Marker Pens
Store Name:Kirti Store
Batch No:Batch2     
Quantity:200            
Unit Price:20

是否要在下拉列表中显示所选的门店项目?@Vishal No。当我从下拉列表中选择门店项目时,我将如何获取其单个值,即单价、批次号、数量。添加了预期输出。是否要在控制器中存储项目详细信息?只想在缩进索引页上显示存储项目。为什么不在存储项目中插入记录??
<table id="datatable" class="table table-striped table-bordered responsive">
 <thead>
  <tr>
   <th>Indent No</th>
   <th>Store</th>
   <th>Expected Date</th>
   <th>Description</th>
   <th>Required</th>
   <th>Issued Type</th>
   <th>Destroy Indent</th>
   <th>Item Name</th>
   <th>Unit Price</th>
   <th>Quantity</th>
   <th>Batch No</th>
   <th colspan="3"></th>
  </tr>
 </thead>

 <tbody>
  <tr>  
   <%@indents.each do |i|%>
    <td><%= i.indent_no %></td>
    <td><%= @stores.name %></td>
    <td><%= i.expected_date%></td>
    <td><%= i.description %></td>
    <td><%= i.required %></td>
    <td><%= i.issued_type %></td>
    <td><%= link_to 'Destroy', destroy_indent_indent_path(i), method: :delete, data: { confirm: 'Are you sure?' },class: "btn btn-danger btn-sm" %></td>

   <% @store_items.each do |s|%>
    <td><%= s.item_name%></td>
    <td><%= s.unit_price %></td>
    <td><%= s.quantity %></td>
    <td><%= s.batch_no %></td>
  </tr>
 <tbody>
<%end%>
<%end%>
def index_indent 
 @store_items = StoreItem.find(params[:id])
 @indents = Indent.all
 @stores = Store.all
end

def new_indent
 @indent = Indent.new
 @store = Store.new
 @store_item = StoreItem.new
end

def create_indent
 @indent = Indent.new(indent_params)
 if @indent.save
  redirect_to index_indent_indents_path
 else
  render 'new_indent'
 end
end
Item Name:Marker Pens
Store Name:Kirti Store
Batch No:Batch2     
Quantity:200            
Unit Price:20