2017-03-09 51 views
0

所以我有控制器命名集合和型號名稱的產品。
集合頁面顯示所有產品。
下面是展會的產品紅寶石軌道合併兩條路線

<% @products.each do |x| %> 
<div class="col-lg-3"> 
    <div class="product-container animated fadeIn"> 
     <div class="product-image-holder"> 
     <%= image_tag x.image1.url(:fhd) %> 
     </div> 
     <div class="product-title-holder"> 
     <span class="product-title"><%= x.title %></span> 
     </div> 
    </div> 
    </div> 
<% end %> 

代碼現在我想包裝每個產品在它自己的鏈接(鏈接到單個產品) 我沒做到這一點,但該鏈接會www.localhost.com /產品/ 1而不是我想成爲www.localhost.com/collection/product/1
任何幫助? :)

這是路線

get 'collection', to:'collection#index' 
    resources :product 
+2

http://guides.rubyonrails.org/routing.html :) – niceman

回答