The application contains a module called Dispute
, this module contains Procedures
, each Procedure
contains a user and belongs to a dispute.
As described below, belongs_to
is not displayed and the :user
attribute is called to return the user (but without the serializer application).
class Dispute::ProceduresSerializer < ActiveModel::Serializer
attributes :id, :user
# FIXME: Not working with belongs_to. Called attribute instead.
# belongs_to :user, serializer: Dispute::UserSerializer
end
class DisputeSerializer < ActiveModel::Serializer
attributes :id
has_many :procedures, serializer: Dispute::ProceduresSerializer
end
Below I describe the associations:
class Dispute::Procedure < ApplicationRecord
belongs_to :dispute
belongs_to :user
end
class Dispute < ApplicationRecord
...
has_many :procedures, dependent: :destroy
...
end
class User < ApplicationRecord
...
has_many :procedures, dependent: :destroy
...
end
Looking at the above code, do you have any idea where the problem is?