Reputation: 1255
undefined method `people_path' for #<#:0x000000023b70c0> Extracted source (around line #4):
Find me in app/views/person/new.html.erb
<% form_for (@person) do |f|%>
<%= f.label :first_name%>
<%= f.text_field :first_name%>
<%= f.label :last_name%>
controller-->
def new
@person = Person.new
end
routes-->
get "person/new"
get "person/index"
get "person/show"
get "person/delete"
get "person/update"
get "person/create"
resources :person
Upvotes: 0
Views: 1556
Reputation: 72514
According to the Rails conventions your controller names must be plural versions of your model names.
For example:
And because the plural of "person" is "people":
This convention is true even for singleton resources!
There are ways to override these conventions, but they are a hassle and take away much from the elegance of Rails routing. In general overriding conventions in Rails often produces "ripple effects" which force you to manually do stuff at other places, too.
In a nutshell: Make your life easy and use the following names:
Person
PeopleController
resources :people
Upvotes: 3
Reputation: 76774
Your problem is here:
#config/routes.rb
get "person/new"
get "person/index"
get "person/show"
get "person/delete"
get "person/update"
get "person/create"
resources :person
According to the Rails Routing documentation, your setting of the routes manually is not in line with convention (RESTful routes). You're best using resources :controller
only:
#config/routes.rb
resources :person
This is taking into consideration that your controller is called persons_controller.rb
(as you stated in your comments)
Upvotes: 0
Reputation: 38645
Given your controller is PeopleController
, update your route file as follows:
# config/routes.rb
# Use plural, i.e. people not person
resources :people
Upvotes: 1