Forum: Ruby on Rails render and render_to_string

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
4e052fdd89cd9ada89361a2ea15c2d8c?d=identicon&s=25 John M. (johnmerlino)
on 2013-03-18 22:22
(Received via mailing list)
render_to_string  returns the result of executing some template or
partial in a string instead of sending it as the response body to the
browser. Render returns the result of evaluating some template or
partial as a string of html, like render_to_string, but it then sends
it back as part of the response body to the browser. Now with ajax,
when I use jquery's get method like this:

    $.get(url, function(resp) {

If I use render_to_string, it sends an actual string back the browser
and thats what is appended to the DOM. When I use render, it returns
HTML back to the browser and thats what is correctly appended to the

So what causes the difference? Does render send as part of the
response body a header like "text/html" or something?
Cf6feecf86654d8005c0f05b2cbbad25?d=identicon&s=25 Tom T. (tom_t)
on 2013-03-19 00:23
(Received via mailing list)
I am currently reading 'Jose_Valim-Crafting_Rails_Application' wherein
he discussed the Rails stack and shows you how this all works.
I am not proficient enough to explain it since I am still trying to
absorb it all but as a reference to the subject I think it will answer
your questions if you are able to get a copy.
0aec98c855572ed6a566bde1dd4034e6?d=identicon&s=25 Jodi S. (jodi_s)
on 2013-03-19 00:25
(Received via mailing list)
what are the differences in the responses reported in the console
etc) ?
This topic is locked and can not be replied to.