In a Rails api project I added this gem for returning json
gem 'jsonapi-serializer'
These are the models I have defined, all very basic stuff going on.
class UserSequel < Sequel::Model(:users)
end
class User < ActiveRecord::Base
end
I generated a serializer class
class UserSerializer
include FastJsonapi::ObjectSerializer
attributes :text
end
Now to the question
# Using ActiveRecord model returns some json as expected
UserSerializer.new(User.first).serializable_hash.to_json
The following however...
# Using Sequel model
UserSerializer.new(UserSequel.first).serializable_hash.to_json
returns this error message
FastJsonapi::MandatoryField (id is a mandatory field in the jsonapi spec)
I don't quite understand why this happens, because obviously the Sequel model contains a column id
and calling this returns the expected outcome
UserSequel.first.id
# => 1