Problem converting application to use REST, people_path meth

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.

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

aurels
http://skartoons.be

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.

routes.rb

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

Hi.
Have you tried that:

map.resources :people

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs