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"}
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 alsocreated_at
andupdated_at
timestamps.Reproduction: