我是新手,我有一个奇怪的问题,我不明白......
我创建了一个只有一个控制器的基本应用程序。此控制器是名称路由(用于测试目的......),它包含索引,新建和编辑操作。
我在routes.rb文件中添加了一个资源:map.resources:routes
我遇到的问题是,当我尝试链接到link_to edit_route_path(某个id)之类的动作时,我得到错误未定义的局部变量或方法`path'for #ActionController :: Routing :: RouteSet:0x101f4d088&gt; < / p>
当我直接使用routes_path时,它可以正常工作。
感谢您的帮助!
rake路线的输出:
路由GET /routes(.:format) {:controller =&gt;“routes”,:action =&gt;“index”}
POST /routes(.:format) {:controller =&gt;“routes”,:action =&gt;“create”}
new_route GET /routes/new(.:format) {:controller =&gt;“routes”,:action =&gt;“new”} edit_route GET /routes/:id/edit(.:format) {:controller =&gt;“routes”,:action =&gt;“edit”}
route GET /routes/:id(.:format) {:controller =&gt;“routes”,:action =&gt;“show”}
PUT /routes/:id(.:format) {:controller =&gt;“routes”,:action =&gt;“update”}
DELETE /routes/:id(.:format){:controller =&gt;“routes”,:action =&gt;“destroy”}
/:控制器/:动作/:ID
/:controller/:action/:id(.:format)
这是我的错误:
#ActionController的未定义局部变量或方法`path':: Routing :: RouteSet:0x101f4d128&gt;
和堆栈跟踪:
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:386:in
generate'
rewrite_path'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:208:in
在/ {/ 1 /} / / / / / / / / / / / /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:625:inrewrite_url'
发送'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:165:in
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:inurl_for'
edit_blog_path'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:in
/Users/guillaume/Projets/rails/testroutes/app/views/blogs/edit.html.erb:4:in`_run_erb_app47views47blogs47edit46html46erb'
ruby版本是1.8.7 宝石版是1.3.7 rails版本是2.3.8
我尝试了从rails开始用户指南的基本帖子脚手架,当我在新页面或编辑页面时我有同样的错误...
ActionController :: Routing :: Routes.draw do | map |
map.resources:routes
map.connect':controller /:action /:id'
map.connect':controller /:action /:id。:format'
结束
奇怪的是,上周一切正常,我不知道我改变了什么......
非常感谢!!!
答案 0 :(得分:0)
转到终端并键入
rake routes
它将显示您的routes.rb文件中定义的所有可能路径。 然后检查编辑route_path是否存在