0

我有这些路线rake routes

     workstations POST   /workstations(.:format)      workstations#create
 new_workstations GET    /workstations/new(.:format)  workstations#new
edit_workstations GET    /workstations/edit(.:format) workstations#edit
                  GET    /workstations(.:format)      workstations#show
                  PUT    /workstations(.:format)      workstations#update
                  DELETE /workstations(.:format)      workstations#destroy
                  POST   /                            workstations#delete_history_and_queue

我认为这link_to是:

= link_to "Update", controller: "workstations", method: "put"

然而我收到了这个错误:

No route matches {:controller=>"workstations", :method=>"put"}

我是否没有指定链接使用workstations带有该方法的控制器put,理论上应该导致该workstations#update操作?

4

2 回答 2

1

尝试

= link_to "Update", edit_workstations_path, :method => :put

或者

= link_to "Update", '/workstations', :method => :put
于 2013-09-24T06:26:44.483 回答
0

我认为您想要以下内容:

= link_to "Update", workstations_path, :method => :put

看起来你在你的 routes.rb 中生成了一个单一的资源......这是故意的吗?

于 2013-09-24T06:41:45.107 回答