Reputation: 211
I'm using jbuilder to build json. When I hit my controller with a .json
request, it works perfectly and I get the appropriate json response. Now I am trying to shove the json into a html5 data attribute (so as to save me the second request to get json). This is all supported within content_tag
. My content_tag
looks like:
<%= content_tag "section", id: "people-container", data: { people: @people } do %>
Loading people...
<% end %>
Within the content_tag
it no longer hits the jbuilder template that I've put together, instead it appears to call the default to_json
on the array of objects (@people
). As such I don't get the json that I do when hitting .json
. Is there a way to force this to go through jbuilder?
Upvotes: 2
Views: 162