This project is archived and is in readonly mode.

render_to_string :template before normal render causes assert_template failures
Reported by Jarl Friis | October 29th, 2010 @ 11:51 PM | in 2.x
When render_to_string :template => ... is called in a controller action and a normal template render later occurs
Tests that uses assert_template will fail claiming that the template is ''
See also ticket #1383 for an earlier similar problem.
Jarl
Comments and changes to this ticket
- 
            
         Jarl Friis October 30th, 2010 @ 12:00 AMThe same problem occurs when using render_to_string :file => ...
- 
         Jeff Kreeftmeijer November 1st, 2010 @ 05:02 PM- Tag cleared.
- Importance changed from  to Low
 Automatic cleanup of spam. 
- 
            
         Jarl Friis November 1st, 2010 @ 07:36 PM- Tag set to 2.3.9, actionpack, activeview, render_to_string
 
- 
         
- 
            
         Jarl Friis November 9th, 2010 @ 11:18 AM- Tag set to 2.3.9, actionpack, actionview, render_to_string
 Added tags again after spam. 
- 
         Neeraj Singh November 9th, 2010 @ 03:57 PMI am not able to reproduce it. Look at the attached test case. Even if this ticket is rendered as invalid the attached patch could be merged because it is strengthening the existing test case. I checked and did not find any test covering the scenario mentioned in the patch. @Jal can you create a small app on github so that I could reproduce the error. Thanks. 
- 
         Neeraj Singh November 9th, 2010 @ 03:58 PMnot open to open the attachment. not sure why. uploading again. 
- 
            
         Jarl Friis November 10th, 2010 @ 01:04 PMNeeraj, done as you requested: 
 https://github.com/jarl-dk/bug5891This is a simple project created with rails bug5891 cd bug5891 ./script/generate scaffold notesNow commit ffa0afcc94f5e9d357ee8d5c5ef94d9a0dd09d7a introduces a reasonable test that assert that the show action uses correct template. This test passes until commit a1ba70ae15a5e114419b2662ecb743f6b4d9a74d) that introduces a render_to_string in the controller that renders some other template (into a string). @Neeraj, could you please from that create a failing test in rails 2.3-stable. I think the reason that you test (in your patch) does not fail is because both render_to_string :template => "test/hello_world"and render :template => "test/hello_world"renders the same template, try to change render_to_stringto render some other template
- 
         Neeraj Singh November 10th, 2010 @ 02:25 PM@Jal thank you. Now I am able to reproduce it. def render_to_string_template_with_template_render #render_to_string :template => "test/hello_world" render_to_string :template => "shared" render :template => "test/hello_world" endI will look into it. 
- 
         Neeraj Singh November 10th, 2010 @ 03:02 PM- State changed from new to open
- Tag changed from 2.3.9, actionpack, actionview, render_to_string to 2.3.9, actionpack, actionview, patched, render_to_string
 Attached is a patch with test cases. Big thanks to Jal for all the help. 
- 
         Neeraj Singh November 10th, 2010 @ 03:03 PM- Milestone set to 2.x
 
- 
         Neeraj Singh November 10th, 2010 @ 08:02 PM- Assigned user changed from josh to José Valim
 Assigning it to Mr. Valim as Josh was last seen in action at LH was in June. 
- 
            
         Jarl Friis November 11th, 2010 @ 09:17 AM@Neeraj: As I mention in comment 2. The problem also occurs if I use render_to_string :file =>Could you make a test that covers that situation as well. 
- 
         Neeraj Singh November 11th, 2010 @ 04:13 PMVerified that this is not an issue with Rails 3. @Jarl I lost my setup for this ticket. Will add to patch once I hear from José Valim to see if I am heading in the right direction. Thanks. 
- 
            
         
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Referenced by
- 
         1383 
          render_to_string :inline before normal render causes assert_template failures  
        Watchers of this ticket may be interested in ticket #5891 1383 
          render_to_string :inline before normal render causes assert_template failures  
        Watchers of this ticket may be interested in ticket #5891
 Jeremy Kemper
      Jeremy Kemper
 José Valim
      José Valim
 josh
      josh
 Neeraj Singh
      Neeraj Singh
 Ryan Bigg
      Ryan Bigg