I have a model called Event, which in turn has_one association with EventType
event = Event.last
event.as_json(include: {event_type: {only: :name}}, only: :event_type)
This is giving me output
{ :event_type=> { "name"=>"Chat" } }
But my desired response is
{ :event_type => "Chat" }
How can I achieve this?
Aucun commentaire:
Enregistrer un commentaire