Closed brentgreeff closed 5 years ago
Yes, in the render jsonapi:
call, your @campaign.activities
get wrapped within instances of SerializableActivity
, which does not happen when you call to_json
directly on your ActiveRecord
s.
You're probably looking for something along the lines of:
renderer = JSONAPI::Serializable::Renderer.new
activities = renderer.render(@campaign.activities)
I want to pass JSON to a react component.
= react_component('ActivityList', props: {activities: @campaign.activities.to_json}, prerender: false)
to_json ignores the
SerializableActivity
Things work fine if rendering from the controller with
render jsonapi: @campaign.activities
How can I get the right JSON in the view?