所以我有名为Collection的控制器和型号名称产品。
收集页面正在显示所有产品。
这是显示产品
<% @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/product/1,而不是我想成为www.localhost.com/collection/collection/product/1
有帮助吗?:)
这是路线
get 'collection', to:'collection#index'
resources :product
使用 scope
scope '/collection' do
resources :products
end
更多信息在此处:http://guides.rubyonrails.org/Routing.html#controller-namespaces-and-louting