Make a custom route for each of the different cases. eg
#in config/routes.rb
get '/clothing/:sex/:option1/:option2/:option3/:option4/:option5', to: 'product#index'
get '/clothing/:sex/:option1/:option2/:option3/:option4', to: 'product#index'
get '/clothing/:sex/:option1/:option2/:option3', to: 'product#index'
get '/clothing/:sex/:option1/:option2', to: 'product#index'
get '/clothing/:sex/:option1', to: 'product#index'
Then in your index action you'll want to do something like
options = [params[:option1], params[:option2], params[:option3], params[:option4], params[:option5]].reject(&:blank?)
condition_strings = ["sex = #{params[:sex]}"]
options.each do |option_string|
choices, category = option_string.split(" ")
condition_strings << "#{category} in (#{choices})"
end
conditions = condition_strings.map{|string| "(#{string})"}.join(" AND ")
@products = Product.find(:all, :conditions => [conditions])
That said, i think this is a really horrible url schema. I would think it would be better to have all the different options as parameters rather than part of the path itself, eg have urls like
www.site.com/clothing?gender=men&type=T-Shirts&brand=Nike&price=100-500&color=Red,White,Blue
This is a much more conventional way of doing things.
EDIT - a rewrite of the above controller-side processing, to make the params structure you want:
options = [params[:option1], params[:option2], params[:option3], params[:option4], params[:option5]].reject(&:blank?)
options.each do |option_string|
choices, category = option_string.split("_")
params[category] = choices
end