I am building a site for users where these can create a bunch of scaffolds 
and for each scaffold the user can create a bunch of tracks. Now, it should 
be possible for a user to share scaffolds with other users (this is were I 
am stuck). Same for tracks.

So the main resources are users, scaffolds and tracks and since I want to 
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
  end
end

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

user
scaffold
track

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 user_id 
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 the 
correct routes.

Help appreciated.

-- 
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+unsubscr...@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/76c65b00-0a69-4a11-93a3-c4d819609f84%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to