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