Reputation: 353
In my rails app, I have a relationship that can be either a has_one or a has_one :through, and I'm not sure how to architect this.
In other words, say I have the classes Foo, Bar, and Baz, the relationship between Foo and Baz could either be:
class Foo
has_one :baz
end
class Baz
belongs_to :foo
end
OR it could be
class Foo
has_one :bar
has_one :baz, through: :bar
end
class Bar
has_one :baz
belongs_to :foo
end
class Baz
belongs_to :bar
end
Does anyone know what the best way is to manage both relationships?
Upvotes: 0
Views: 59