mercredi 7 septembre 2016

rails url as breadcrumb

Feature request for SEO optimized url :- (friendly url only replaces id with the name/title),

Current URL Washing Machine is: //localhost:3000/products?product_category_id=15#WashingMachine Custom URL for the same page should be: (as per bread-crumbs) http://localhost:3000/HomeEssentials/Cleaning&Drying/WashingMachine Where HomeEssentials > Cleaning&Drying > WashingMachine is the bread crumbs, and it has the parent child menu structure.

This has to happen at every product category, and for ex, product?product_category_id=35#Football, in terms of breadcrumbs :- Home > Sports & Leisure > Football. (leading to a url like - localhost:3000/Home/Sports&Leisure/Football.)

I have had a look at friendly url gem, and stubs, and changing to_param in the model , but that effectively replaces the id with the title/name, or any parameter we set. However it does not replace the entire url, in the manner as expected. (the answer probably lies in changing the routes file, (mapping, etc) but have not received much success in my search so far). Currently, the request is being generated from the home page, into the -

products controller and the parameter product category id is being passed.

  • <%= link_to subMenuCat_tab.name, products_path(:product_category_id => subMenuCat_tab.id) %>

Any suggestion / help in this regards would be highly appreciated.

Aucun commentaire:

Enregistrer un commentaire