Is there a RESTful way to configure routes for habtm?
Asked Answered
P

1

8

In Rails you can use nested routes to create RESTful routes for has_one and has_many relationships. Examples can be found on the Rails Guides

I'd like to ask if there is a good way to configure RESTful routes for habtm relationships? For example if I have a relationship A-habtm-B, my idea is to configure nested routes for A has_many B, and nested routes for B has_many A. Would that work? Or is there a better way?

Provence answered 22/1, 2009 at 13:16 Comment(0)
H
5

Since HABTM is a two way has_many association, your approach is correct and nested resources on both sides will work just fine. Other than that, I would reconsider using a has_many :through association instead of HABTM, since it's more versatile.

Herbertherbicide answered 22/1, 2009 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.