ruby-rdf / linkeddata

A metadistribution of RDF.rb including all parsing/serialization plugins.
http://rubygems.org/gems/linkeddata
The Unlicense
51 stars 9 forks source link

Inclusion of gem breaks Rails/ActiveRecord #14

Closed eins78 closed 4 years ago

eins78 commented 4 years ago

When the linkeddata gem is included in a Rails application, it somehow breaks ActiveRecord Models. I found a workaround (only include what we need instead of this whole distribution) but I wanted to report it because it very strange. I could not believe it myself at first, but its reproducible in a freshly generated app.

Observed Problem: Model-Instances are missing some properties, notably id(!) and in the case of our app also created_at and updated_at timestamps.

Reproduction:

bundle exec rails new myapp # Using rails 6.0.3.1
cd myapp
bin/rails generate model thing
bin/rails db:migrate
bin/rails runner 'Thing.create'

# everything still works, instance has `id`:
bin/rails runner 'puts Thing.first.id != nil'
# -> true

# now add the gem
echo "gem 'linkeddata'" >> Gemfile
bundle
# its broken!
bin/rails runner 'puts Thing.first.id != nil'
# -> false

# just to make sure, yes the data is correct in the db:
bin/rails runner 'puts ActiveRecord::Base.connection.execute "SELECT * from things;"'
# -> {"id"=>1, "created_at"=>"2020-06-16 15:21:56.770811", "updated_at"=>"2020-06-16 15:21:56.770811"}
gkellogg commented 4 years ago

This is likely related to ruby-rdf/sparql#35, which I'll have a fix out for shortly.

gkellogg commented 4 years ago

This should be fixed now, please update gems and try again.

eins78 commented 4 years ago

confirmed the fix (using linkeddata 3.1.2 (was 3.0.3)). thanks!