class Moderation
belongs_to :content
end
class Content
has_many :moderations
end
class ModerationResource < ApplicationResource
type :'moderation'
model ::Moderation
# Note : use has_one despite having the belongs_to key to pass the moderation to the contentResource !
has_one :content, resource: ::Moderation::ContentResource
end
class Moderation::Content < ApplicationResource
type :'moderation'
model ::Moderation
def update(attributes, moderation)
# If we had used a `belongs_to` in the resource, +moderation+ would be nil !
ModerationService.new(moderation).update_content_attributes(attributes)
end
end