Noobie here. Let's say you have a Post, Comment, and User models. So
Post has_many comments, and User has_many comments.
If it good practice to do the following...
resources :posts do
resources :comments
end
resources :users do
resources :comments
end
etc?
I have a model in my schema that I believe I will likely have 3
different route resources for.
Or is better to just have the one, such as our first snippet of code
above, and then have a param that modifies what is returned, in this
example, passing in the user_id to just see comments for that user?
When doing this, does this mean both of these resources would access the
same controller? How can I have them access different controllers, and
what would a proper naming convention be for each controller in your
example?
If you’re referring to the comments resource, yes, both would post to the same controller in your format as well as the one I suggested. If you want them to point to different controllers, you will need to go back to your original format and specify a controller, such as: