Denix
September 30, 2008, 5:00pm
1
I want such urls in at site:
http://mysite.com/freddy/profile/view
http://mysite.com/freddy/blog/view
…
so I want username in my url, and it should use controllers from
folder: member
And I use this route:
map.username ":username/:controller/:action/:id",
:controller => 'member/:controller',
:action => ':action',
:id => ':id',
:requirements => { :username => /[a-zA-Z0-9_]+/}
But it gives me error: “wrong constant name :controllerController”.
What’s wrong?
Denix
October 2, 2008, 4:59pm
2
Denix wrote:
I want such urls in at site:
http://mysite.com/freddy/profile/view
http://mysite.com/freddy/blog/view
…
so I want username in my url, and it should use controllers from
folder: member
And I use this route:
map.username ":username/:controller/:action/:id",
:controller => 'member/:controller',
:action => ':action',
:id => ':id',
:requirements => { :username => /[a-zA-Z0-9_]+/}
But it gives me error: “wrong constant name :controllerController”.
What’s wrong?
Hey Denix,
Here is an example from the rails api regarding “Regular Expressions and
Parameters”:
map.geocode ‘geocode/:postalcode’, :controller => ‘geocode’,
:action => ‘show’, :postalcode => /\d{5}(-\d{4})?/
Kind of similar to your example, no? If I were to re-write your write,
it might look something like this:
map.username “:username/:controller/:action”,
:controller => ‘member’,
:action => ‘show’,
:requirements => { :username => /[a-zA-Z0-9_]+/}
Hope this helps a bit, read more about routing here:
http://api.rubyonrails.org/classes/ActionController/Routing.html