Reputation: 18511
I currently have the following code and it works fine:
respond_to do |format|
format.json { render :show, status: :ok }
end
I believe :show
is referring to a jbuilder view.
However, if I wanted to add a local variable to the json render, how would I do that?
I've tried the following but it hasn't worked.
auth = true
format.json { render :show, :include => auth, status: :ok }
and I've also tried
auth = true
format.json { render :show.include(auth), status: ok }
From what I found at render :json does not accept options
Upvotes: 3
Views: 1475
Reputation: 2296
try this one
format.json { render :show, locals:{auth: auth}, status: :ok }
now you have a variable auth in your show view
Upvotes: 4