Using build with a has_one association in rails.
Posted
by espinet
on Stack Overflow
See other posts from Stack Overflow
or by espinet
Published on 2010-03-18T20:01:52Z
Indexed on
2010/03/18
20:11 UTC
Read the original article
Hit count: 224
This is a really noob question but im having trouble finding the answer, is there a way in rails to have 0 or 1 association? For example, I create a user with no objects, than later on create an object for that user.
I tried using build with a 'has_one' association but that blew up... The only way I see this working is using 'has_many'. The user is suppose to only have at most one of these objects, is there any way to do this?
© Stack Overflow or respective owner