rails/rails — Issue #5069: has_many association build/create method is overwrite forign_key
Author: suzukis
Created: 2012-02-17 04:07:22+00:00
State: open

Behavior of build / create method created has_many association differs by rails 2 and rails 3.0 and after rails3.1

```ruby
class Blog < AR:Base
has_many :entries
end
class Entry < AR:Base; end

b = Blog.create
b.id # => 1

#rails 2.3
e = b.entries.build(:blog_id => 999)
e.blog_id # => 1
e = b.entries.create(:blog_id => 999)
e.blog_id # => 1

#rails 3.0.11
e = b.entries.build(:blog_id => 999)
e.blog_id # => 1
e = b.entries.create(:blog_id => 999)
e.blog_id # => 999

#rails 3.1.3 / 3.2.1
e = b.entries.build(:blog_id => 999)
e.blog_id # => 999
e = b.entries.create(:blog_id => 999)
e.blog_id # => 1
```