本文介绍了Ruby on Rails-将ID参数添加到所有路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道在Rails路由中实现以下功能的最佳方法是什么:
I am wondering what is the best way to implement the following functionality in the Rails routing:
方案:用户注册帐户的网站=> accountID(帐户)成为网站内的主要实体。
Scenario: an website where users sign up for accounts => accountID (Account) becomes the main entity within the website.
示例:-将授权用户带到Basecamp仪表板。从这里开始,所有URL都包含:accountID,如
Read more here: http://guides.rubyonrails.org/routing.html#prefixing-the-named-route-helpers
更新:以下是整个示例,其中包括仪表板默认路线
Update: Here's an entire example including your "dashboard" default route
scope ":account_id" do
root :to => "dashboard#index" # http://example.com/12323/
resources :projects # http://example.com/12323/projects
resources :todos # http://example.com/12323/todos
...
end
这篇关于Ruby on Rails-将ID参数添加到所有路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!