我想要这样的路线:
get '/posts/new' => 'posts#new'
get '/:username/posts/:id' => 'posts#show'
get '/:username/posts' => 'posts#index'
可通过以下助手访问:
new_post_path #=> new -
post_path(post) #=> show - :username implied from post
posts_path #=> index - :username implied from session
posts_path(user) #=> index - :username explicit
我想用足智多谋的语义来做到这一点,而不是手动指定每条路线。另外我不确定如何使 url 助手变得聪明。
想法?