Customized URL-Rewriting

In my rails application, i did custom URL rewrite since then my project navigation will look like this,

http://localhost:3000/   — redirecting to index page
http://localhost:3000/home
http://localhost:3000/profile

For doing this you have to write  the map condition in your rails rout.rb files. The will be like this,

As in my application just want to show simplified custom url as above for that in the route.rb i wrote like this,

map.home ‘/home’,:controller=>”signup”, :action=>”update”

map.profile ‘/profile’,:controller=>”signup”, :action=>”profile”

In my view section for those  navigation, i.e link_to tage look like this,

<%= link_to “Home” , {:controller => “signup”, :action => “signup”} %>

<%= link_to “Profile” , {:controller => “signup”, :action => “profile”} %>

That’s all to get the desired Custom URL.

Note:

For more info on URL rewrite can get here :
http://guides.rails.info/routing.html

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: