Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with routing and path
    text
    copied!<p>I am new to rails and I have a weird problem i don't understand...</p> <p>I have created a basic application with only one controller. this controller is name routes (for testing purpose...) and it contains index, new and edit actions.</p> <p>I have added a resource in the routes.rb file: map.resources :routes </p> <p>The problem I have is when i try to make a link to an action like link_to edit_route_path(some id) I get the error undefined local variable or method `path' for #ActionController::Routing::RouteSet:0x101f4d088></p> <p>When I use routes_path directly, it works fine.</p> <p>Thanks for your help!</p> <p>output of rake routes:</p> <blockquote> <p>routes GET /routes(.:format) {:controller=>"routes", :action=>"index"}<br> POST /routes(.:format) {:controller=>"routes", :action=>"create"}<br> new_route GET /routes/new(.:format) {:controller=>"routes", :action=>"new"}<br> edit_route GET /routes/:id/edit(.:format) {:controller=>"routes", :action=>"edit"}<br> route GET /routes/:id(.:format) {:controller=>"routes", :action=>"show"}<br> PUT /routes/:id(.:format) {:controller=>"routes", :action=>"update"}<br> DELETE /routes/:id(.:format) {:controller=>"routes", :action=>"destroy"}<br> /:controller/:action/:id<br> /:controller/:action/:id(.:format) </p> </blockquote> <p>this is the error I have:</p> <blockquote> <p>undefined local variable or method `path' for #ActionController::Routing::RouteSet:0x101f4d128></p> </blockquote> <p>and the stack trace:</p> <blockquote> <p>/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:386:in <code>generate'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:208:in</code>rewrite_path'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:187:in <code>rewrite_url'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:165:in</code>rewrite'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:625:in <code>url_for'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:in</code>send'<br> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:in <code>url_for'<br> (eval):17:in</code>edit_blog_path'<br> /Users/guillaume/Projets/rails/testroutes/app/views/blogs/edit.html.erb:4:in `_run_erb_app47views47blogs47edit46html46erb' </p> </blockquote> <p>ruby version is 1.8.7 gem version is 1.3.7 rails version is 2.3.8</p> <p>I tried the basic posts scaffold from the rails getting started user guide and i have the same error when I am in the new page or edit page...</p> <blockquote> <p>ActionController::Routing::Routes.draw do |map|<br> map.resources :routes<br> map.connect ':controller/:action/:id'<br> map.connect ':controller/:action/:id.:format'<br> end </p> </blockquote> <p>The weird thing is that everything was working fine last week and I don't know what i have changed...</p> <p>Thank you very much!!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload