Rails routes can be customized as your own routes with parameters but first you should understand how routes behaves.
Adding dynamic parameters to routes
Here exact parameters are matched to route and presence of each parameter is mandatory in order to construct urls. blank parameter will raise RoutingError exception.
Exact matched named route declared as -
match ':a/:b/:c', :to => 'home#index', :as => :q
now go to the rails console -
ruby-1.9.3-head :005 > app.q_url(:a, :b, :c)
=> "http://www.example.com/a/b/c"
ruby-1.9.3-head :006 > app.q_url(:a, :b, '')
ActionController::RoutingError: No route matches {:controller=>"home", :a=>:a, :b=>:b, :c=>""}
Bound parameters to named routes
If you are too sure that certain parameter can be blank then you can define it as optional parameter inside route -
match ':a/:b(/:c)', :to => 'home#index', :as => :q
rails console
ruby-1.9.3-head :010 > app.q_url(:a, :b, '')
=> "http://www.example.com/a/b?c="
ruby-1.9.3-head :011 > app.q_url(:a, :b)
=> "http://www.example.com/a/b"