On Feb 17, 4:14 pm, Abhishek shukla [email protected] wrote:
Hello Friends,
I want to configure personalized url for e.g. -http://localhost:3000/xyzherexyz is a database value. Now for the
same i have implemented the
following syntax inside my route.rb file
map.url ‘/:name’, :controller => ‘controller_name’, :action => ‘action_name’
But now when ever i run my application the action_name.rhtml appears
whereever i click.
That sounds like its working.
map.name “/:name”, :controller => “people”, :action => “show”
map.connect “:controller/:action.:format”
will see a url like “http://localhost:3000/anything”
and match it to the first route.
it will do the same for “http://localhost:3000/admin”
and hence always try and grab PeopleController#show
what you’d need to do is declare any important routes before that
eg.
map.admin “/admin”, :controller => “admin”
map.name “/:name”, :controller => “people”, :action => “show”
map.connect “:controller/:action.:format”
this will make sure that “http://localhost:3000/admin” goes to the
right place.
My suggestion is if you’re just starting out in rails,
keep it simple.
http://localhost:3000/people/Abishek
looks just as nice,
but is much simpler for a newbie.
Enjoy.