jashmenn / activeuuid

Binary uuid keys in Rails
MIT License
340 stars 124 forks source link

Primary key column_hash is binary != :uuid #65

Open markalanevans opened 9 years ago

markalanevans commented 9 years ago

On this line: https://github.com/jashmenn/activeuuid/blob/master/lib/activeuuid/uuid.rb#L146

self.class.columns_hash[primary_key].type => binary

which != :uuid

The db is mysql, i'm using the mysql2 gem and the field is a binary 16 field in the DB.

Version

activeuuid (0.6.0) activerecord (>= 3.1) uuidtools

ghost commented 9 years ago

add a file activeuuid.rb in your project config/initializers will fix this issues

ActiveRecord::Base.connection_pool.with_connection do
  ActiveUUID::Patches.apply!
end
benjaminjackson commented 8 years ago

Why is this needed? I see the patches being applied in the code here:

https://github.com/jashmenn/activeuuid/blob/master/lib/activeuuid.rb#L9

And here:

https://github.com/jashmenn/activeuuid/blob/master/lib/activeuuid/railtie.rb#L9