# Problem converting application to use REST, people\_path meth

**URL:** <https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894>\
**Category:** Rails\
**Created:** [August 24, 2007, 6:30am UTC](https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894 "2007-08-24T06:30:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![anthonyrudgick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@anthonyrudgick](https://www.ruby-forum.com/u/anthonyrudgick)\
**Post date:** [August 24, 2007, 6:30am UTC](https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894/1 "2007-08-24T06:30:41Z")

</div>

Hi All,

I am converting a “traditional” rails application to use RESTful routes  
and controllers. Everything is going fine so far, except for the  
following problem.

I have the active record class Person. When I want to build RESTful  
URL’s using the helper \*\_path methods the person\_path(:id) calls work  
fine, but when I use people\_path method ruby raises an exception that no  
method exists. I assume these methods are created dynamically, why would  
the method for creating "show"URL’s get created, but not the method for  
the “index” URL?

example code:

# This works fine. The call to person\_path(@person) generates the

correct URL

# this is uses for updating an existing person.

\<% form\_for(:person, :url =\> person\_path(@person), :html =\> { :method  
=\> :put }) do |form| %\>

First Name \<%=  
form.text\_field :first\_name %\>

  

Last Name \<%=  
form.text\_field :last\_name %\>

  
\<% end %\>
# The following call to people\_path fails with a the eror

# |undefined local variable or method `people\_path’ for

#\<#Class:0xb7065ca4:0xb7065c7c\>

# this is used when creating new users.

|\<% form\_for(:person, :url =\> people\_path, :html =\> { :method =\> :put })  
do |form| %\>

First Name \<%=  
form.text\_field :first\_name %\>

  

Last Name \<%=  
form.text\_field :last\_name %\>

  
\<% end %\>

I have tried variants like persons\_path with no success. People is the  
correct pluralization used by rails.

Cheers,

Anthony R.

---

<div class="post-metadata">

**Author:** ![anthonyrudgick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@anthonyrudgick](https://www.ruby-forum.com/u/anthonyrudgick)\
**Post date:** [August 24, 2007, 1:42pm UTC](https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894/2 "2007-08-24T13:42:42Z")

</div>

Hi. And what’s the content of your “routes.rb” file?

aurels  
[http://skartoons.be](http://skartoons.be)

---

<div class="post-metadata">

**Author:** ![anthonyrudgick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@anthonyrudgick](https://www.ruby-forum.com/u/anthonyrudgick)\
**Post date:** [August 28, 2007, 7:50am UTC](https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894/3 "2007-08-28T07:50:10Z")

</div>

Aurélien Malisart wrote:

> Hi. And what’s the content of your “routes.rb” file?
> 
> aurels  
> Hi,

# routes.rb

ActionController::Routing::Routes.draw do |map|  
map.connect ‘’, :controller =\> “home”  
map.resources :person  
end

However, all routing seems to work fine. I have no problems with  
get,put,post,delete calls.

Cheers,

Anthony R.

---

<div class="post-metadata">

**Author:** ![anthonyrudgick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c37758/32.png) [@anthonyrudgick](https://www.ruby-forum.com/u/anthonyrudgick)\
**Post date:** [August 30, 2007, 4:26pm UTC](https://www.ruby-forum.com/t/problem-converting-application-to-use-rest-people-path-meth/112894/4 "2007-08-30T16:26:38Z")

</div>

> # routes.rb
> 
> ActionController::Routing::Routes.draw do |map|  
> map.connect ‘’, :controller =\> “home”  
> map.resources :person  
> end

Hi.  
Have you tried that:

map.resources :people
