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) { $(''#tabs'').append(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 DOM. So what causes the difference? Does render send as part of the response body a header like "text/html" or something? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
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. On Mar 18, 4:21 pm, John Merlino <stoici...-YDxpq3io04c@public.gmane.org> wrote:> 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) { > $(''#tabs'').append(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 > DOM. > > So what causes the difference? Does render send as part of the > response body a header like "text/html" or something?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
what are the differences in the responses reported in the console (firebug, etc) ? On Mon, Mar 18, 2013 at 7:22 PM, fuzzy <hlogoma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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. > > On Mar 18, 4:21 pm, John Merlino <stoici...-YDxpq3io04c@public.gmane.org> wrote: > > 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) { > > $(''#tabs'').append(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 > > DOM. > > > > So what causes the difference? Does render send as part of the > > response body a header like "text/html" or something? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.