mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Fix #3247.
Fixes creating records in a through association with a polymorphic source type.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
class User < ActiveRecord::Base
|
||||
store :settings, accessors: [ :color, :homepage ]
|
||||
end
|
||||
|
||||
|
||||
u = User.new(color: 'black', homepage: '37signals.com')
|
||||
u.color # Accessor stored attribute
|
||||
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
|
||||
@@ -37,6 +37,12 @@
|
||||
|
||||
[Aaron Christy]
|
||||
|
||||
*Rails 3.1.2 (unreleased)*
|
||||
|
||||
* Fix creating records in a through association with a polymorphic source type. [GH #3247]
|
||||
|
||||
[Jon Leighton]
|
||||
|
||||
*Rails 3.1.1 (October 7, 2011)*
|
||||
|
||||
* Add deprecation for the preload_associations method. Fixes #3022.
|
||||
|
||||
@@ -44,7 +44,7 @@ module ActiveRecord
|
||||
join_attributes = {
|
||||
source_reflection.foreign_key =>
|
||||
records.map { |record|
|
||||
record.send(source_reflection.association_primary_key)
|
||||
record.send(source_reflection.association_primary_key(reflection.klass))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -825,4 +825,9 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase
|
||||
def test_explicitly_joining_join_table
|
||||
assert_equal owners(:blackbeard).toys, owners(:blackbeard).toys.with_pet
|
||||
end
|
||||
|
||||
def test_has_many_through_with_polymorphic_source
|
||||
post = tags(:general).tagged_posts.create! :title => "foo", :body => "bar"
|
||||
assert_equal [tags(:general)], post.reload.tags
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user