Has_many :through distant relationships

I have the following associations:

disks->disks_user_files<-user_files

my models look like:

class Disk < ActiveRecord::Base
has_many :disk_user_files
has_many :user_files, through => :disk_user_files
end

class DiskUserFile < ActiveRecord::Base
belongs_to :disk
belongs_to :user_file
end

class UserFile < ActiveRecord::Base
has_many :disk_user_files
has_many :disks, :through => :disk_user_files
end

So far so good.
I want to extend this to something like

disks->disks_user_files<-user_files<-users

so I add :belongs_to :user to my UserFile class
and add:

class User < ActiveRecord::Base
:has_many :user_files
end

The problem I’m having is associating users all the way back through
user_files and disk_user_files to disks
Any help would be appreciated.

Jon

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs