From what I have read, I can respond to a json request by using the following code:
respond_to do |format|
format.json { render json: t.response }
end
My problem is that t.response is already in json format – and I think that my app is breaking because render json: is re-converting it to json. How do I avoid this, and simply return t.response.
Note that if I simply have t.response as my last line in the controller, the corresponding view is rendered – which is obviously not json.
Thanks!
EDIT: I am trying to get this working so I can send sms via tropo. If you have used tropo before, do you have any suggestions how to respond back to tropo correctly?
I’ll show you how Rails deals with converting to json format. It’s basically on line:
So, strings aren’t converted, other objects are converted to String via their
to_jsonmethod. If yourt.responsereturns a string then no conversion is performed.