Forum: Ruby on Rails Planning an application - what is the optimal MVC setup?

952d96687009292ee0748ce3af7c10eb?d=identicon&s=25 Martin Asser Hansen (Guest)
on 2013-08-01 16:38
(Received via mailing list)
I am building a site for users where these can create a bunch of
and for each scaffold the user can create a bunch of tracks. Now, it
be possible for a user to share scaffolds with other users (this is were
am stuck). Same for tracks.

So the main resources are users, scaffolds and tracks and since I want
display an index for each of these I have chosen nested routes so in the
routes.rb file I have:

resources :users do
  resources :scaffolds do
    resources :tracks

I have the the following models and corresponding controllers and views:


In the models user has_many :scaffolds, scaffold has_many :tracks and
belong_to :user and track belong_to :scaffold

For the sharing I have a scaffold_relationship and a track_relationship
model both with sharing and shared attributes in which I can store
and scaffold_id/track_id. Thus I can use the has_many
:scaffold_relationships, foreign_key: "shared_id" and has_many :sharing,
through :scaffold_relationships. Same for the track_relationship.

However, I am unsure if this is the way to go. I think I want separate
scaffold and track sharing pages, and maybe it is better with separate
resources for the relationships? In any case I am stuck with planning
correct routes.

Help appreciated.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.