In the Rails 3 docs, the build
method for associations is described as being the same as the new
method, but with the automatic assignment of the foreign key. Straight from the docs:
Firm#clients.build (similar to Client.new("firm_id" => id))
I've read similar elsewhere.
However, when I use new
(e.g. some_firm.clients.new
without any parameters), the new client's firm_id
association is automatically created. I'm staring at the results right now in the console!
Am I missing something? Are the docs a bit out of date (unlikely)? What's the difference between build
and new
?