Make has_one building syntax to look the same as for has_many
15 views
Skip to first unread message
Alex Galushka
unread,
Apr 8, 2016, 5:09:15 PM4/8/16
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Sign in to report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ruby on Rails: Core
classUser has_many :tips has_one :photo end
user.tips.build(params) user.photo.build(params)
Currently we have to use different syntax user.build_photo because user.photo can return nil. We can return some kind EmptyRecord instance the support the same methods that we have for has_many