2017-03-09 42 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

回答