Forum: Ruby on Rails resource api docs not working for me

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
itsastickup (Guest)
on 2009-01-01 15:02
(Received via mailing list)

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

should result in this lot:

  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;

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/
POST   /people/invitations
POST   /people/invitations.:format
new_people_invitation GET    /people/invitations/new
formatted_new_people_invitation GET    /people/invitations/
edit_people_invitation GET    /people/invitations/:id/edit
formatted_edit_people_invitation GET    /people/invitations/:id/
people_invitation GET    /people/invitations/:id
formatted_people_invitation GET    /people/
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


anyone got any ideas. What have I missed.
Tyler Crocker (Guest)
on 2009-01-04 04:29
(Received via mailing list)
I'm not entirely sure what you were trying to do with the singular
thing. Rails should automatically pluralize or singularize words for
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
just want a page for each person that lists that person's invitations,
I think you can/should say;
> map.resources people do |person|
> > person.resource invitations
> end

I hope this helps.

This topic is locked and can not be replied to.