Favorite Quotes:
"...it ain't about how hard ya hit. It's about how hard you can get it and keep moving forward. How much you can take and keep moving forward. That's how winning is done!" (Rocky Balboa)
" We cannot change the cards we are dealt, just how we play the hand." (Randy Pausch)
Rails 3.1: new and build work alike !
19-Jan-12, 05:51AMJust realized this today that in Rails 3.1 new and build work alike ! Here is an example:
Assuming we have two models: Client & Document and Client has many documents
In Rails 3:
| new | build |
client = Client.last client.documents.new client.documents => [] | client = Client.last client.documents.build client.documents => [#<Document id: nil, client_id: 1>] |
In Rails 3.1
| new | build |
client = Client.last client.documents.new client.documents => [#<Document id: nil, client_id: 1>] | client = Client.last client.documents.build client.documents => [#<Document id: nil, client_id: 1>] |