So I’m working on a new rails project which involves running multiple website from a single rails installation. I am confuse on how to do the association without nesting the resources.
note: I am using subdomains so url would be site1.ex.com/photos,
site2.ex.com/ramps
For example now I have a site named site 1 and site 1 has photos, videos, and ramps. I can do the association by telling rails site has_many :photos, :videos, :ramps(Code is not formatted properly just giving you the idea). Everything works fine including url but here is my problem.
- site is included in the url which is something I do not want(ex. example.com/sites/1/photos).
- Association works fine but what if I would like to have parents for the 3 items? Rails suggests you do not nest routes over 1 level deep.

Here is what I would like to do

- How can I called the association between site without using nested resources(Can’t capture the site_id with album_id for photos)?
- If album has_many :photos and belongs_to :site how can I call that in my controller(Any examples)?
Am rails newb so I’ve added pictures so someone could understand what I am trying to accomplish.
If you use subdomains, you don’t have to use nested resources for
sites. To find a site:For all the other resources, you nest them not under
Sitebut use themselves as the parent (Album/Photos, Videos, Ramps). And in yourAlbumsControlleryou will want only those that belong to the site with the current subdomain, so you make use of your before_filter from theApplicationControllerand use the@siteobject: