I'm stumped by this stupid newbie error I'm seeing... trying to figure out where to "look" next... (undefined method xxx_path )

On one of my new.html.erb files backed by a "matches_controller" I'm getting the error:

undefined method `matches_path' for #<ActionView::Base:0x2cfc748>

I don't understand where to start looking to try to understand why I'm getting this error. Even if I back everything out of the page and just have:

<h1>New match</h1> <% form_for(@match) do |f| %> <% end %>

I still get the error.

What am I supposed to do to start tracking now where the issue is? Is it that I'm getting an error message that isn't directly related at all to the 'matches_path" issue. Other pages aren't having this issue, so I'm a bit stumped.

I'm a rails newb (but seasoned java person so I have no problem looking in logs for errors.. but the errors don't seem to be helping me track down the 'reai' issue.)

Thanks for any direction of what to start looking at (is it maybe an obscure error in my controller or another page causing the problem?)

Rick wrote:

On one of my new.html.erb files backed by a "matches_controller" I'm getting the error:

undefined method `matches_path' for #<ActionView::Base:0x2cfc748>

I don't understand where to start looking to try to understand why I'm getting this error. Even if I back everything out of the page and just have:

<h1>New match</h1> <% form_for(@match) do |f| %> <% end %>

I still get the error.

What am I supposed to do to start tracking now where the issue is? Is it that I'm getting an error message that isn't directly related at all to the 'matches_path" issue. Other pages aren't having this issue, so I'm a bit stumped.

I'm still a relative newby, so no worries :slight_smile:

It's a routing problem. The form_for tries to generate a route relating to the matches controller, but the route doesn't exist. Either you want to add something like

map.resources :matches

to config/routes.rb, or manually add a route in that same file, pointing to the controller/action you want. The resources mapping will generate a whole load of routes for that controller that use the RESTful principles.

You can add that above line and then run "rake routes" to list the structure. The new routes generate buy the line will be shown and should let you see what it does.

HTH

Matt

Awesome. Thanks so much! I had created the other pages using the scaffolding (which explains those entries in the routes.rb) but not for this one (matches) which I manually started to make. Scaffolding is nice but learn so much more from these mistakes doing it yourself that you helped me with . Thanks again.

  map.resources :name_of_controller, '/route'

Correcting the first entry - don't know how that copy and paste got in there:

map.resources :name_of_controller, :only => :index