views:

17

answers:

2

Hey guys,

I'm working on a ruby on rails project currently, doing it without scaffolding or anything just by hand. I have an index controller that simply lists all existing items in the db with a link on each that redirects to a details view.

The error I am getting is when trying to link to the item I have this line of code:

<%= link_to "Show", person %>

this is the same line of code I see everywhere, even in other working apps, I know person is the right variable name but no idea why this is failing. The error I get at runtime is:

undefined method `person_path' for #<ActionView::Base:0x7fe4d07f6568>

any helpful hints?

+2  A: 

Check your "routes.rb" file. Make sure you have a declaration similar to: map.resources :people

If you open terminal and run "rake routes", it will show you all routes that are currently recognized by your app.

dave
ahhh, one of the frustrating things about rails, knowing what's going on behind closed doors, it should handle this behavior by default! ugh, thank you
Jimmy
A: 

Sounds like the route for Person is not configured properly. Is the app using REST-ful routing? Read more at: http://guides.rubyonrails.org/routing.html

arnab