Thursday, 15 September 2011

Rails 3 Routes - prepend all url paths with set string -


I have been asked to change the route on a rail project that the route will only respond to requests where the name of the app (or Other arbitrary string) is the first string after the domain name, e.g.

instead of www.thething.com/appname/users/sign_in www.thething com / users / sign_in

< Code> www.thething.com/appname instead of www.thething.com

www.thething.com/appname/search Instead of www.thething.com/search

I have suggested using a subdomain instead, but the client about the url's willingness in the above format Very specific.

www.thething.com will be a splash page with a link to www.thething.com/appname , in the future, new folders in the future Intended to add additional apps / pages with names.

Is there an easy way to modify the routes so that all the routes

< / Div> "text">

An option wraps all existing routes into: namespace: appname ... Termination , such as:

  # config / routes.rb Appname :: Application.routes.draw namespaces: APNM # Existing routes have expired here   

I'm not sure that this is the most beautiful solution, but it's all the routes For / appname will be done first.

No comments:

Post a Comment