Skip to content

Instantly share code, notes, and snippets.

@ziyan-junaideen
Created April 17, 2015 07:48
Show Gist options
  • Save ziyan-junaideen/323ab76d8b871ffd691f to your computer and use it in GitHub Desktop.
Save ziyan-junaideen/323ab76d8b871ffd691f to your computer and use it in GitHub Desktop.
class Site < ActiveRecord::Base
belongs_to :domain
# has_one :account, through: :domain # Stack level too deep
end
class Domain < ActiveRecord::Base
has_one :account, through: :site
has_one :site
end
class Account < ActiveRecord::Base
has_many :sites, through: :domains
has_many :domains
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment