0
我的路線應該是這樣的:這些導軌路徑應該如何看起來像?
>rake routes
GET /categories/:category_id/articles(.:format) {:controller=>"articles", :action=>"index"}
category_articles POST /categories/:category_id/articles(.:format) {:controller=>"articles", :action=>"create"}
new_category_article GET /categories/:category_id/articles/new(.:format) {:controller=>"articles", :action=>"new"}
GET /categories/:category_id/articles/:id(.:format) {:controller=>"articles", :action=>"show"}
PUT /categories/:category_id/articles/:id(.:format) {:controller=>"articles", :action=>"update"}
category_article DELETE /categories/:category_id/articles/:id(.:format) {:controller=>"articles", :action=>"destroy"}
edit_category_article GET /categories/:category_id/articles/:id/edit(.:format) {:controller=>"articles", :action=>"edit"}
GET /categories(.:format) {:controller=>"categories", :action=>"index"}
categories POST /categories(.:format) {:controller=>"categories", :action=>"create"}
new_category GET /categories/new(.:format) {:controller=>"categories", :action=>"new"}
GET /categories/:id(.:format) {:controller=>"categories", :action=>"show"}
PUT /categories/:id(.:format) {:controller=>"categories", :action=>"update"}
category DELETE /categories/:id(.:format) {:controller=>"categories", :action=>"destroy"}
edit_category GET /categories/:id/edit(.:format) {:controller=>"categories", :action=>"edit"}
,但每當我嘗試,文章,使用以外的任何其他 new_category_article_path,
<%= link_to 'Show', categories_article %>
我得到這意味着例外:
undefined local variable or method 'categories_article' for #<#<Class:0x00000102ce5768>:0x00000102ce3a80>
這是什麼我在這裏做錯了?
非常感謝,mattyven! – Jan 2010-08-19 11:19:22
只是還有一件事 - 是否有一個語法來做其他動作的最短版本,比如編輯? – Jan 2010-08-19 11:31:22
<%= link_to'Show',[a.category,a]%>給出與<%= link_to'Edit',[a.category,a],:action =>「edit」%>相同的結果,我從文檔中查找 – Jan 2010-08-19 11:42:46