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

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2701c824d560c66c31b3d58d36fe17cf?d=identicon&s=25 itsastickup (Guest)
on 2009-01-01 14:02
(Received via mailing list)
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.
903f6242fbf82051b35eb3be368e1ebd?d=identicon&s=25 Tyler Crocker (Guest)
on 2009-01-04 03:29
(Received via mailing list)
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
This topic is locked and can not be replied to.