Using build method in has_one and has_many associations for Ruby on Rails

I learned using build method the hard way yesterday. I did not know that there is a subtle difference in way you use build method for has_one association and has_many association in Ruby on Rails. Say we have two associations like these.

  1. Human has_one head
  2. Human has_many fingers

Say we already have belongs_to statement for both head and fingers. For the first case, human has_one head assoication, you instantiate a head by the following statement.
@human.build_head

For the second case with has_many association, you instantiate finders by doing this.
@human.fingers.build

This is also confirmed by A Guide to Active Record Associations.

When initializing a new has_one or belongs_to association you must use the build_ prefix to build the association, rather than the association.build method that would be used for has_many or has_and_belongs_to_many associations. To create one, use the create_ prefix.