Reputation: 13548
Let's say that you have a resource that is created and displayed entirely within the view of another resource (eg. comments or tags). Should you still make it it's own resource, or would it be a better idea to make it a nested resource? Also, should you make use of virtual attributes?
I know this question is general, but I'm not looking for a specific answer, just a general explanation of when each technique is preferred.
Upvotes: 1
Views: 118
Reputation: 27217
Some general thoughts:
Upvotes: 1
Reputation:
Generally speaking, it would be more useful to make it a nested resource. This is the more "RESTful" way. It will also give you access to the parent resource without having to specify it as a parameter. However, you do not want to nest a resource more than one level deep, as noted in the Rails routing guide.
Upvotes: 1