I have a participant
model that return a polymorphic relationship called participable
, I need return the type of relationship instead of type participable
. I am using at frontend Ember.
class ParticipantSerializer < ApplicationSerializer # :nodoc:
attributes :id
belongs_to :dispute
belongs_to :participable, polymorphic: true
end
In my case the issue is not with the polymorphic association, is with the app logic.
I fix it creating another associations through participants
:
has_many :participants
has_many :users, through: :participants, source: :participable, source_type: 'User'
has_many :mediators, through: :participants, source: :participable, source_type: 'Mediator'
I hope this help.