0
votes

I am new to rails and I have a weird problem i don't understand...

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.

I have added a resource in the routes.rb file: map.resources :routes

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>

When I use routes_path directly, it works fine.

Thanks for your help!

output of rake routes:

routes GET /routes(.:format) {:controller=>"routes", :action=>"index"}
POST /routes(.:format) {:controller=>"routes", :action=>"create"}
new_route GET /routes/new(.:format) {:controller=>"routes", :action=>"new"}
edit_route GET /routes/:id/edit(.:format) {:controller=>"routes", :action=>"edit"}
route GET /routes/:id(.:format) {:controller=>"routes", :action=>"show"}
PUT /routes/:id(.:format) {:controller=>"routes", :action=>"update"}
DELETE /routes/:id(.:format) {:controller=>"routes", :action=>"destroy"}
/:controller/:action/:id
/:controller/:action/:id(.:format)

this is the error I have:

undefined local variable or method `path' for #ActionController::Routing::RouteSet:0x101f4d128>

and the stack trace:

/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:386:in generate'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:208:in
rewrite_path'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:187:in rewrite_url'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/url_rewriter.rb:165:in
rewrite'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:625:in url_for'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:in
send'
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/url_helper.rb:85:in url_for'
(eval):17:in
edit_blog_path'
/Users/guillaume/Projets/rails/testroutes/app/views/blogs/edit.html.erb:4:in `_run_erb_app47views47blogs47edit46html46erb'

ruby version is 1.8.7 gem version is 1.3.7 rails version is 2.3.8

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...

ActionController::Routing::Routes.draw do |map|
map.resources :routes
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end

The weird thing is that everything was working fine last week and I don't know what i have changed...

Thank you very much!!!

1
I am having the same results as sachinrathore, can you add to the post the routes.rb file (minus the comments please) and the code that is generating the error, also where are you putting this code. I am a bit confused as to what is returning the routeset and then throwing path on it. Also which version of rails are you using?Geoff Lanotte
I don't have access to my project currently but my routes.rb is very basic. It contains the default routes at the end of the file and one map.resources :routes, that's all. for the version, I have the latest one (2.3.8)glatour
Ok, me too and not able to replicate. I am not sure without seeing code, but one thing to check is that you haven't run into any reserved names accidentally - perhaps with a gem or something. Try renaming it to something a little off-the-wall just to be sure. So map a resource map.resources :angus and see if you are able to replicate that way.Geoff Lanotte
correction, map.resources :anguses unless the plural of angus is angi? anyone? ;)Geoff Lanotte

1 Answers

0
votes

Go to terimnal and type

rake routes

It will show you all possible routes define in your routes.rb file. Then check edit_route_path is there or not