Best route for has_many subrecords

Hello all,
I have a model, say it’s called Person, which has_many Responsibilities.
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
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
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
of a has_many association) into a RESTful route. Perhaps wanting to do
sort of thing from the “show” view is not compatible with RESTful

I suppose I could create a controller just for the Responsibilities
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?


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs