0
我要像一個路線:通過像傭工如何使用足智多謀的語義/語法來製作這些路線+助手?
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 helpers變得聰明。
雖然?
我想要非典型的嵌套路線。 '/ users /:user_id/posts',而不是'/:username/posts'。這就是拋棄我。 – 2013-04-04 20:26:15
對不起,我複製了錯誤的東西。查看更新的答案。我認爲這是'match'進來的地方。 – Catfish 2013-04-04 20:28:53