开发者

How to get alternative info from a routing namespace in rails?

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

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
end


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

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

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜