Add local variable to response_to render view
I currently have the following code and it works great:
respond_to do |format|
format.json { render :show, status: :ok }
end
I believe this is :show
referring to the jbuilder view.
However, if I wanted to add a local variable to the json rendering, how would I do it?
I tried the following but it didn't work.
auth = true
format.json { render :show, :include => auth, status: :ok }
and i also tried
auth = true
format.json { render :show.include(auth), status: ok }
From what I found in render: json takes no parameters
+3
source to share