drnic/composite_primary_keys — pull request #110 by jnv (2012-06-04 00:47:13+00:00)
Title: Multiple assignments to same column due to duplicate keys in @changed_attributes

I've encountered quite rare problem with CPK while using Devise or CarrierWave. Under some conditions, `@changed_attributes` hash (used by AttributeMethods::Dirty) can contain duplicated attributes – symbol and string. See ce7eb75d4917b622e2099617957885b451ccfc96 for straightforward example. In the end, the resulting query contains 2 assignments to the same field:

```sql
UPDATE "reference_types" SET "abbreviation" = 'b', "abbreviation" = 'b' WHERE "reference_types"."reference_type_id" = 1
```

The funny part is that most DB systems happily accept such query. PostgreSQL does not.

Rails already prevent this by conversion of attribute key to string.
I also had to fix some associations test since the hash from `ActiveModel::Dirty#changes` uses string keys for assertion – otherwise this shouldn't affect anyone since this method returns a HashWithIndifferentAccess.

Anyway, I think that the preferred solution would be to call the original method, since both are basically same (except for intercepting an Array).
I'm not sure how to do it since I don't understand how the method is overridden in this case – `alias :[]= :write_attribute` doesn't ring any bells.