S
S
Shaks2017-04-11 14:36:10
Ruby on Rails
Shaks, 2017-04-11 14:36:10

What relationship between models to choose?

There is a model, let's call it Landing, and also a model TemplateI want to Landingbe able to have a one-to-one relationship with the model Template, and Templatein turn have a one-to-many relationship. Those. Landingcan have one Template, and the same one Templatecan be assigned to several Landing
has_one :through- great, but I don't need an intermediate model. It suggests a link through a join table. has_and_belongs_to_many- also good, but not what I need, because Landingshould have a one-to-one relationship, not a one-to-many relationship.
What do you gentlemen advise?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Andreev, 2017-04-11
@shaks

What was wrong with has_many/belongs_to?

Template
  has_many :landings

Landing
  belongs_to :template

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question