Forum: Ruby on Rails Best route for has_many subrecords

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.
Ed437e52d8d6720308720e7e678f3e6d?d=identicon&s=25 Patrick Doyle (Guest)
on 2008-12-03 06:08
(Received via mailing list)
Hello all,
I have a model, say it's called Person, which has_many Responsibilities.
I
would like the "show" view for the person controller to list all of the
responsibilities for that person.  (That's the easy part -- I think I
know
how to do that part.)  At the end of the list, I would like to include a
text field into which a new responsibility may be added.  What route
should
I use for the "Add" button next to that text box?

I am, perhaps, confused, because I'm using RESTful routing, and I can't
figure out how to map this sort of action (add/update one of the
subrecords
of a has_many association) into a RESTful route.  Perhaps wanting to do
this
sort of thing from the "show" view is not compatible with RESTful
routing.

I suppose I could create a controller just for the Responsibilities
model,
and I could nest the routes for that inside the routes for the Person
routes, but that seems like overkill, especially since I only need to be
able to create and edit responsibilities.

Or is it?  Is that the "Rails Way" to do this sort of thing?

--wpd
This topic is locked and can not be replied to.