I Rails if you have a model Walrus that has_many :bubbles
(and Bubble belongs_to :walrus
, you can create a new Bubble that is associated with the Walrus like so:
chuckles = Walrus.create
chuckles.bubbles.create
But what if Walrus has_one :bubble
? chuckles.bubble.create
is a no go (as it is nil
). How can I do the equivalent without just passing in the Walrus in the Bubble.create
?