Is there a way to append data (e.g. {:foo => 6}
) for all json responses so codes such as render :json => {..}
would become {"foo": 6, ...}
?
I tried to create a json layout in app/views/application.json.erb but didn't seem to make a difference.
The code I'm using is often similar to:
respond_to do |format|
format.html
format.json { render json: {..} }
end
I kind of got it working when using a json view but it is a bit cumbersome to create a view for each response.