开发者

Problems with routing and path

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:inrewrite_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:inrewrite'

/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:insend'

/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:inedit_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!!!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜