4

我的路线:

resources :events, :path_names => { :new => "organize" } do
    resources :forums
end

通过这些路线,我会得到像/events/:event_id/forums/organize. 我不希望 path_names 传播到我的嵌套路由......我是否必须path_names为它们重新定义?还是使用scope

resources :events, :path_names => { :new => "organize" } do
    scope :path_names => { :new => "new" } do
        resources :forums
        # other nested resources...
    end
end

或者(我最喜欢的,直到你找到更好的解决方案;))

resources :events, :path_names => { :new => "organize" }
resources :events, :only => [] do
    #nested resources...
end

有没有更优雅的方法来做到这一点?如果你不这么认为,你也可以告诉我你认为哪一个是最好的。

4

1 回答 1

0

我选择了最后一个选项:

resources :events, :path_names => { :new => "organize" }
resources :events, :only => [] do
    #nested resources...
end
于 2012-01-21T15:17:49.773 回答