Anthony Richardson
2007-Aug-24 04:29 UTC
Problem converting application to use REST, people_path method not found
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| %> <p><label for="employee_first_name">First Name</label> <%= form.text_field :first_name %></p> <p><label for="employee_last_name">Last Name</label> <%= form.text_field :last_name %></p> <% 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| %> <p><label for="employee_first_name">First Name</label> <%= form.text_field :first_name %></p> <p><label for="employee_last_name">Last Name</label> <%= form.text_field :last_name %></p> <% end %> I have tried variants like persons_path with no success. People is the correct pluralization used by rails. Cheers, Anthony Richardson --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aurélien Malisart
2007-Aug-24 11:41 UTC
Re: Problem converting application to use REST, people_path method not found
Hi. And what''s the content of your "routes.rb" file? aurels http://skartoons.be --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Aurélien Malisart
2007-Aug-30 14:25 UTC
Re: Problem converting application to use REST, people_path method not found
> # routes.rb > ActionController::Routing::Routes.draw do |map| > map.connect '''', :controller => "home" > map.resources :person > endHi. Have you tried that: map.resources :people --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---