ruby on rails - Design where all associations tie to a team / community -


i'm interested in hearing how people design , set i'm inexperienced scenario.

take example rails application allow people create teams. each team can have many projects, comments, members , other resources.

how structure avoid deep linking f.ex:

nested_comment.root_comment.project.team

i see becoming problematic quite quickly, causing both performance issues , in general not comfortable work with.

routes become complicated if team id present always, f.ex: example.com/:team_name

resources :teams   resources :projects     resources :comments   end end 

i know can shallow nesting, issue see here can use slug still require deep linking. furthermore shallow won't avoid going more 1 level deep, document recommends not doing.

resources should never nested more 1 level deep. 

what potentially f.ex still needs 2 levels deep.

resources :teams   resources :projects, shallow: true    resources :comments   end   resources :comments, only: [:show, :edit, :update, :destroy] end 

by not having teams main resource, you'd open security issues people can edit other teams comments , projects unless keep adding validations @ controller , model level ensure user has access. people use trees or something?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -