更新时间:2022-04-18 01:25:51
您可以使用范围
:
scope ":username", :as => "user" do
resources :things
end
将此与code> to_param 在用户型号上:
Combine this with to_param
on the user model:
def to_param
username
end
你会有路由,如 / username / things
。注意,用户名不应包含任何点,斜线或标准URI字符。您可能希望在用户名
的末尾夹上参数化
。确保。
And you'll have routes such as /username/things
. Be careful though, the username shouldn't contain any dots, forward slashes or standard URI characters. You may want to chuck a parameterize
on the end of username
to make sure.