2013-07-10 78 views
0

這是我的表:Ruby on Rails的 - 形式表

index.html.erb: 



    <center><table border="1" cellspacing="0" cellpadding="10" id="c"></center> 
    <h3><center>List Of Products</h3></center> 

    <tr> 
    <th>S.No</th> 
    <th>Products</th> 
    <th>Availble Quantity</th> 
    <th>Price(each per kg/qua)</th> 
    <th>Quantity Requried<br>(enter required qua as per kg/qua)</br></th> 
    </tr > 
    <% @product.each do |product| %> 

    <tr> 
    <td><center><%= product.id %></center></td> 
    <td><center><%= check_box_tag "name" %> <%= product.name %></center></td> 
    <td><center><%=product.quantity %></center></td> 
    <td><center><%= product.price %></center></td> 
    <td><center><input type= "text" style="width:50px;"></center></td> 
    </tr> 
    <% end %> 
    </table><br><br> 
    <%= link_to "ADD",checkout_index_path, class: "btn btn-small btn-primary" %> 

我的問題是,如果我選擇任何複選框它應該顯示在下一頁的選擇字段(即:index.html.erb /結帳)

我index.html.erb /結帳頁面:

<p id="notice"><%= notice %></p> 
    <h5>Slected products are:</h5> 
    <%= link_to 'Continue Online Shopping', products_path %> 

例如,如果我選擇第1項,並單擊添加按鈕,它應該在結帳顯示所選項目進行頁面。幫我!!!!!

所選項目應在此index.html.erb /結帳頁面

+0

...而你在取什麼?錯誤信息?什麼是參數?等等? –

回答

0

你必須把你的表一表內顯示。是這樣的:

<%= form_tag :form_products, checkout_index_path do |f| %> 

您應該定義爲: <%= check_box_tag 「名稱[#{product.id}]」 %>

,然後在結賬動作,你將得到所有的參數: params ['name'] [i] =='1' 其中我是產品編號