Ruby on rails 什么';通过scaffold生成的视图中存在错误函数调用的?
我已经为元素搭建了脚手架:Ruby on rails 什么';通过scaffold生成的视图中存在错误函数调用的?,ruby-on-rails,ruby,scaffold,Ruby On Rails,Ruby,Scaffold,我已经为元素搭建了脚手架: script/generate scaffold wip/thing name:string 在视图中得到了一些无效的函数调用,如: <td><%= link_to 'Edit', edit_thing_path(thing) %></td> rake routes告诉我: wip_things GET /wip/things(.:format)
script/generate scaffold wip/thing name:string
在视图中得到了一些无效的函数调用,如:
<td><%= link_to 'Edit', edit_thing_path(thing) %></td>
rake routes告诉我:
wip_things GET /wip/things(.:format) {:action=>"index", :controller=>"wip/things"}
POST /wip/things(.:format) {:action=>"create", :controller=>"wip/things"}
new_wip_thing GET /wip/things/new(.:format) {:action=>"new", :controller=>"wip/things"}
edit_wip_thing GET /wip/things/:id/edit(.:format) {:action=>"edit", :controller=>"wip/things"}
wip_thing GET /wip/things/:id(.:format)
我假设这些名称(wip_thing,new_-wip_thing)是正确的名称,但它仍然给我这个错误
谢谢。此方法来自routes.rb文件。如果您有一个resource:thing define,那么所有这些方法都将在控制器/视图中定义 如果您:
map.resources:things
如果您没有此资源,则无法定义此方法
在Ruby on Rails指南上查看此资源:
您可以通过rake任务了解所有这些路线:
rake路由
明白了!该方法应符合以下建议:
rake routes
但应具有后缀_路径:
<%= link_to 'Edit', edit_wip_thing_path(@thing) %>
我有这个资源,但在名称空间中定义了:map.namespace:wip do | wip | wip.resources:things end这有什么问题吗?是的。脚手架定义不带命名空间的路由。您需要使用此命名空间定义url。查看rake路由查看真正的routeOk,我运行了rake路由,得到了“new\u-wip\u-thing-GET/wip/things/new(:format){:action=>“new”,:controller=>“wip/things”}”,所以我尝试在我的视图中使用“new\u-wip\u-thing”,但仍然会产生错误。知道我做错了什么吗?
rake routes
<%= link_to 'Edit', edit_wip_thing_path(@thing) %>