有沒有寫這個的更簡潔的方式:在一個聲明中創建兩個型號的紀錄
> e = Entity.create(name: 'foo')
#<Entity id: 1, name: "foo", created_at: "2014-07-25 13:57:08", updated_at: "2014-07-25 13:57:08">
> l = Location.create(address: 'New York, NY')
#<Location id: 1, address: "New York, NY", created_at: "2014-07-25 13:57:08", updated_at: "2014-07-25 13:57:08">
> e.location = l
> e.save
這不起作用:
> Entity.create(name: 'foo').location.create(address: 'New York, NY')
實體has_one
位置,如果是相關。