我正在研究的Rails应用程序中有许多不同的模型.我见过许多网站都使用了应用程序范围的slug路由方法.这是什么意思?
http://example.com/nick-oneill <-- This points to a User object
http://example.com/facebook <-- This points to a Company object
http://example.com/developers <-- This points to the users#index page
Run Code Online (Sandbox Code Playgroud)
我知道to_param并在应用程序中创建了读者友好的slug,但是我不知道有一种方法可以为各种对象提供根级别的slug.你可以认为这类似于Facebook的Graph API:有不同的对象类型,但它们都存在于https://graph.facebook.com/object-id
任何见解都将非常感谢!