Wednesday, August 11, 2010

Ruby on Rails: Route: Change routing / url link

1. Show "mydomain.com/products" instead of "mydomain.com/catalogs/list"

Add this line to /config/routes.rb

map.connect 'products', :controller => 'catalogs', :action => 'list'


2. Retrieve url parameter: www.domain.com/products/34/d24s34/book

Add this line to /config/routes.rb

map.connect 'products/:id/:ref/:type', :controller => 'catalogs', :action => 'list'


catalogs_controller.rb

@id = params[:id]
@reference = params[:ref]
@type = params[:type]


No comments:

Post a Comment