Take the 2-minute tour ×

Imagine you are working on a f,acebook(to skip the g,f,w) like site, and you need some routes like:

  • www.mydomain.com/ihome/jim/posts
  • www.mydomain.com/ihome/jim/post/3
  • www.mydomain.com/ihome/jim/posts/3/edit.

Then how to set the routes to get the 'jim' part? I know I can use the following if there is no account part:

namespace :ihome do
  resources :posts
share|improve this question

1 Answer 1

up vote 3 down vote accepted

A quick (untested) answer is : use the scope, it will give you a params[:user]

namespace :ihome do
  scope ":user" do
    resources :posts

Have a look at the docs here : http://guides.rubyonrails.org/routing.html#defining-defaults

share|improve this answer

Your Answer


