2013-09-24 35 views
0

我从运行rake routes这些航线的航班:为什么不`link_to`去我指定

 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操作?

回答

1

尝试用

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

OR

= link_to "Update", '/workstations', :method => :put 
0

我想你想以下几点:

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

它看起来像你产生在你的routes.rb单一资源。 ..是故意的吗?

相关问题