Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Format chosen when calling render_to_string gets used in subsequent render #5440

Closed
jcoleman opened this Issue Mar 14, 2012 · 10 comments

Comments

Projects
None yet
2 participants
Contributor

jcoleman commented Mar 14, 2012

Suppose I do:

render_to_string :template => "template", :formats => [:text]

and then later call:

render_to_string :template => "template", :formats => [:html]

if the template has a render :partial => "partial" call in it, in the render_to_string call with format set to :html, the partial will be rendered again as the format :text instead of :html.

This is on 3-2-stable. It does not manifest itself in the 3.2.2 release (though the 3.2.2 release has a Content-Type setting bug that is now fixed on 3-2-stable--which is why I moved up to the branch.)

drogus added a commit to drogus/rails that referenced this issue Mar 15, 2012

Member

drogus commented Mar 15, 2012

Does that test above look like something that fails for you? It passes on 3.2. Could you try to push sample app to github or try to update the test to make it fail?

jcoleman added a commit to jcoleman/rails that referenced this issue Mar 15, 2012

Contributor

jcoleman commented Mar 15, 2012

Two things on the test case:

  1. Why do you expect the content type to be set on the response to text/html? This is unrelated to the problem I had, but give that you specified the format :text for your render call, should it set the content type to text/plain?
  2. I modified your test case to mimic my issue and as expected, I get an error. The partial I try to render only exists in html form, and the call to render partial (incorrectly) gets the option :formats => [:text]. You can see that test above.
Member

drogus commented Mar 15, 2012

@jcoleman thanks for clarification. I'll try to fix that.

Contributor

jcoleman commented Mar 15, 2012

@drogus I'm still curious why you expected (in your original test) the content type to be set to text/html. Is there something I'm missing here? Shouldn't the content type be set to the format you request in rendering?

Member

drogus commented Mar 15, 2012

@jcoleman oops, sorry, I forgot about the first question. It's there by mistake - I just copied one of the tests that had it and forgot to remove or change to text/plan (which probably should be end result because of :formats => :text)

Contributor

jcoleman commented Mar 15, 2012

@drogus The reason I ask is that is because you said the original test passed on 3.2. That implies that might be a test that should actually be a failing case as well (for a different bug perhaps.)

Member

drogus commented Mar 15, 2012

@jcoleman yes, you're right with that, I've already added the second one to check if correct format is set when template with different format is rendered before.

@drogus drogus closed this in 1eb6189 Mar 17, 2012

josevalim added a commit that referenced this issue Mar 17, 2012

Member

drogus commented Mar 17, 2012

@jcoleman could you check if 3-2-stable works for you now?

Contributor

jcoleman commented Mar 18, 2012

I've verified both the tests and that it works in my project.

Member

drogus commented Mar 18, 2012

@jcoleman thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment