Applying style to the URLs

Hi you all,
I have a link with two params:
<%= link_to “John S.”, { :action => “filtered_list”, :value => “John
Smith”, :property=> “primaryCharacter” }, :post => true %>

The URL appears as:
/wiki/filtered_list?value=John+Smith&property=primaryCharacter

My question is, could I get another style in the link, such as:
/wiki/filtered_list/John+Smith/primaryCharacter
(I mean, in the same way as when we use :id param)

Or even hide the params on the url? (this could be eventually done by
using a form with hidden fields, but this is not my idea…)

Sure, in routes.rb…

map.connect '/wiki/filtered_list/:value/:property, :controller =>
‘wiki’, :action => ‘filtered_list’

You could also do something like this…

map.connect '/wiki/list/:value/:property, :controller =>
‘wiki’, :action => ‘filtered_list’

In other words, the URL doesn’t have to match the controller or
action names.


Building an e-commerce site with Rails?
http://www.agilewebdevelopment.com/rails-ecommerce

You should be able to do this in your routes:

map.connect ‘/wiki/filtered_list/:value/:property’, :controller =>
‘wiki’, :action => ‘filtered_list’

The url should then be formatted as per your question. This is just
off the top of my head and could likely be improved on, but it should
give the idea.

Hope that helps,

Steve

Damaris F. wrote:

/wiki/filtered_list/John+Smith/primaryCharacter
(I mean, in the same way as when we use :id param)

Or even hide the params on the url? (this could be eventually done by
using a form with hidden fields, but this is not my idea…)

Damaris,
edit routes.rb in config to cutomize how your URL’s would look, for
example:

map.connect “wiki/:action/:value/:property”, :controller =>
‘your_controller’

hope that helps,
Bojan


Bojan M.
Informatika Mihelac, Bojan M. s.p. | www.informatikamihelac.com
→ tools, scripts, tricks from our code lab: http://source.mihelac.org

Wow!

Thanks all of you! :smiley: