How to write link_to method to Rails route globbing

doabit
2011-08-25T19:07:26Z

I have a product page,I want to change the url  "example.com/products/
list?category_id=1&price_id=5&type_id=2&sort_by=name&......"
to

"example.com/products/list/category_id/1/price_id/5/type_id/2/sort_by/
name.....".
my routes like

  match ''/products/list(/*specs)'', :controller =>
''products'', :action
=> ''list'',:as => :list_products
My controller

  @products=Product.scoped
  @products = @Product.where(Hash[*params[:specs].split("/")]) if
params[:specs]
In my views:

  Categories:
  <% Category.all.each do |category| %>
<%= link_to category.name,list_products_path(:specs =>
[''category'', category]) %>
  <% end %>
  Price:
  <% Prices.all.each do |price| %>
<%= link_to price.name,list_products_path(:specs =>
[''local'',
local]) %>
  <% end %>
I wnat to get url like /products/list/category/1/local/2... ,but it
can only get url like /products/category/1 or /news/local/2. How to
write the link_to method to make it works? Thank you.

--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at