rails/rails — Issue #3292: Relational addition through has_many :through via polymophic association doesn't work.
Author: condor
Created: 2011-10-11 11:06:18+00:00
State: open

There are 3 models.

```ruby
class Tag < ActiveRecord::Base;end
```

```ruby
class TagsTaggedItem < ActiveRecord::Base
belongs_to :tag
belongs_to :tagged_item, :polymorphic => true
end
```

```ruby
class Event < ActiveRecord::Base
has_many :tags_tagged_items, :as => :tagged_item
has_many :tags, :through => :tags_tagged_items
end
```

Under the relation above, the code below become to work wrongly. The insertion into the table 'tags_tagged_items' leaves its value for 'tagged_item_type' nil. It comes with Rails 3.1.

```ruby
event = Event.first
tag = Tag.first
event.tags << tag # work wrongly
```