Reputation: 967
I have 2 controllers. One is to render html page with react. One is to act as rest api. For the second one (rest api), I have a JBuilder file to render the json response. Now for the first controller (HTML one), I want to re-use the JBuilder file in the controller 2 so that I can render the first response (in json) to a div element and then I can re-use that in react.
My question again is how to re-use the JBuilder template in controller 2? Thanks,
Upvotes: 1
Views: 1055
Reputation: 754
You can insert render partial into the erb(slim/haml) file:
<%= raw render(:template => "path/view.json", :locals => { :var => @var}) %>
Upvotes: 1