Ruby on Rails Tuesday, June 10, 2014

IMO, it can be done either way.  If you use routes, it would be a little cleaner when you are using the same resource more than once to make a concern:

concern :commentable do
   resources :comments
end

resources :posts, concerns: [:commentable]
resources :users, concerns: [:commentable]

On Monday, June 9, 2014 3:00:28 PM UTC-4, Ruby-Forum.com User wrote:
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?

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2a818622-cc09-43c4-9d50-dff69f993b08%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment