Resource api docs not working for me


#1

Hi,

ruby 1.8.4, rails 2.2.2, mongrel 1.5.1, win xp

I read in the docs that this :

map.resources :articles do |article|
article.resources :comments
end

should result in this lot:

article_comments_url(@article)
article_comment_url(@article, @comment)

article_comments_url(:article_id => @article)
article_comment_url(:article_id => @article, :id => @comment)

So when I did my own idea of the above :

map.resource :people,:singular=>:person do |person|
person.resources :invitations;
end

I was surprised to find no method such as person_invitations (with or
without the :singular=>true): all the methods are pluralised for
people. And for those methods that do exist none take the person id,
even the index method (which makes it useless to me). Here is what
rake is telling me are my routes:

people_invitations GET /people/invitations
formatted_people_invitations GET /people/
invitations.:format
POST /people/invitations
POST /people/invitations.:format
new_people_invitation GET /people/invitations/new
formatted_new_people_invitation GET /people/invitations/
new.:format
edit_people_invitation GET /people/invitations/:id/edit
formatted_edit_people_invitation GET /people/invitations/:id/
edit.:format
people_invitation GET /people/invitations/:id
formatted_people_invitation GET /people/
invitations/:id.:format
PUT /people/invitations/:id
PUT /people/invitations/:id.:format
DELETE /people/invitations/:id
DELETE /people/invitations/:id.:format

Ideally I want to be able to do

link_to person_invitations(@person)

and get

href="/people/2/invitations"

anyone got any ideas. What have I missed.


#2

I’m not entirely sure what you were trying to do with the singular
person
thing. Rails should automatically pluralize or singularize words for
you.
And if you wanted singular then just say;> map.resource person

but if you’re going to have multiple persons then you’ll want the;

map.resources people

With the invitations, are those supposed to be individually accessed? If
you
just want a page for each person that lists that person’s invitations,
then
I think you can/should say;

map.resources people do |person|

person.resource invitations
end

I hope this helps.

-Tyler