jashmenn / activeuuid

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

Rails 5 compatibility #76

Closed spdawson closed 8 years ago

spdawson commented 8 years ago

In a clean Rails 5.0.0.beta1 project, adding

gem 'activeuuid'

to the Gemfile causes the following failure to start the server.

$ bundle exec rails s
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from require at /var/lib/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:77)
/var/lib/gems/2.2.0/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'activeuuid'. (Bundler::GemRequireError)
daande commented 8 years ago

What happens if you run rails s without the bundle exec?

Also I currently see that warning and it is not a fatal error however I am using Nginx as a reverse proxy into Puma and it runs my web app fine.

spdawson commented 8 years ago

As you say, this is in fact just a warning. On further investigation, the real error in the logs is the following.

ActiveRecord::StatementInvalid (Mysql2::Error: Data too long for column 'id' at 
row 1: INSERT INTO `visits` (`id`, `visitor_id`, `ip`, `user_agent`, `landing_pa
ge`, `browser`, `os`, `device_type`, `screen_height`, `screen_width`, `country`,
 `latitude`, `longitude`, `started_at`) VALUES (x'63333263363761362d326534332d34
6139352d623764312d646535396263393739633864', x'64326262353263662d633337662d34336
4392d386630652d303536393735376432316164', '127.0.0.1', 'Mozilla/5.0 (X11; Linux 
i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.82 Safari/537.36',
 'http://localhost:3000/', 'Chrome', 'Linux', 'Desktop', 768, 1366, 'Reserved', 
0, 0, '2016-01-24 11:51:32')):

I'm using activeuuid to support Ahoy with MySQL.

daande commented 8 years ago

This is actually a configuration issue on your end / Ahoy issue. You are trying to have an ID that is "x'63333263363761362d326534332d346139352d623764312d646535396263393739633864" which is too long for your column.

emilford commented 8 years ago

@spdawson What did you do to address this issue? I'm currently experience the same thing while attempting to upgrade an app to Rails 5. Any pointers would be appreciated.

spdawson commented 8 years ago

@emilford I was lucky in that ahoy no longer has a dependency on activeuuid; so I was just able to drop the activeuuid dependencies in my own Rails apps.

blackham commented 8 years ago

@spdawson I wish I would have read your message two hours ago. But, if anyone needs to use activeuuid with rails 5. (Or with Ruby 2.3) I started the work to remove all that alias_method_chain stuff that is causing errors. I got the code to run, but I didn't test it. All the changes are in the /lib/activeuuid/patches.rb file (attached as a .txt file)

My understanding is the included needs to be replaced with prepended. After that you can call super and avoid all that nasty alias_method_chain stuff. Again, I only got it to run without crashing. I didn't test it.

patches.rb.txt

jashmenn commented 7 years ago

@blackham - I've added you as a collaborator to this repo. Feel free to push commits and/or merge pull requests

tilo commented 6 years ago

@jashmenn @blackham any update on Rails 5 compatibility?