我有一系列想要编辑的项目。编辑我的URL的当前格式时,显示如下:
http://mysite/items <---- Lists the items
http://mysite/items/1/ <------ more detailed view of items
http://mysite/items/1/edit <----- Ability to edit the item我想尝试将路由配置应用于我的结构,如下所示:
http://mysite/items <---- Lists the items
http://mysite/item <---- Detailed view of the item by sending the item ID as POST data
http://mysite/item/edit <---- Edits the item by sending the item ID as POST data这是一个严格的rails路由配置事件,还是我必须配置items页面中的链接才能明确地构造URL。
发布于 2012-11-02 11:42:55
试试这个:
#config/routes.rb
#assuming your actions are in ItemsController
match 'items' => 'items#index', :via => :get
match 'item' => 'items#show', :via => :post
match 'item/edit' => 'items#edit', :via => :post请注意,这更适用于遗留应用程序/URL,因为Rails约定遵循RESTful映射。有关详细信息,请访问the routing guide。
https://stackoverflow.com/questions/13188163
复制相似问题