I've got a controller that gets some data from the database and an html view is rendered nicely in my browser.
Now I need to bootstrap some json in my html (to be used by javascript).
I add the following code to render json in the controller:
@my_json = render_to_string(template: 'dimension_types/index.json.jbuilder')
I do nothing else, just add this code to my controller and what happens is that the browser now just shows my page's html code. In the html source my page is wrapped in <pre></pre>
tags.
There's no error in the logs. I tried adding layout: false, passing various combinations of handlers and formats to render -- nothing changes.
What am I doing wrong? What part of the documentation am I missing?