Permutation on Rails Routes

Posted by Kevin Sylvestre on Stack Overflow See other posts from Stack Overflow or by Kevin Sylvestre
Published on 2010-06-02T18:34:45Z Indexed on 2010/06/03 16:54 UTC
Read the original article Hit count: 204

Filed under:

I currently have an application that for a set of parameters (location, category, budget, ...) a user can enter a "pretty" URL like:

/location/canada/ontario
/category/primary
/budget/small

Resulting in the respective parameters:

params[:country] == 'canada' and params[:region] == 'ontario'
params[:category] == 'primary'
params[:budget] == 'small' 

I want to allow users to perform searches on multiple parameters at once (with each parameter optional). For example:

/location/canada/ontario/category/primary/budget/small

I understand that this can be achieved using URL parameters, but for SEO reasons I prefer to add the "pretty" parameters. Is this at all possible without listing all possible combination of routes (I have a large number of search-able fields)? I understand that route "globbing" maybe play a roll, but I am not sure how.

Thanks.

© Stack Overflow or respective owner

Related posts about ruby-on-rails