build association for has_one in rails

Problem

You would like to use the build method for creating an association (details) that belongs to another assocation (user).
When the user has many details then you would have something like the following:

then you could do:

but when you have:

would throw an error:

Solution

In order to be able to use the build in a has_one relation you would need to use like: