Skip to content

Instantly share code, notes, and snippets.

@kelso
Created November 13, 2013 15:10
Show Gist options
  • Select an option

  • Save kelso/7450618 to your computer and use it in GitHub Desktop.

Select an option

Save kelso/7450618 to your computer and use it in GitHub Desktop.
has_many :relationships
has_many :people, through: :relationships
# stredovy model, ktory patri pod obidve - Person aj Account
belongs_to :person
belongs_to :account
has_many :ownerships
has_many :accounts, through: :ownerships
# pouzitie
account = Account.find(1)
person = account.people.build(email: "x", password: "y")
person.save
# alebo z druhej strany
person = People.find(1)
account = person.accounts.build(company: "z")
account.save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment