This project is archived and is in readonly mode.

render_to_string is completely broken
Reported by Jaroslaw Zabiello | June 2nd, 2008 @ 09:12 AM
class MyController < ApplicationController
  def index	 
    @x = render_to_string :controller => 'i_do_not_exists'
  end
end
There is no exception raised if I use :controller which does not exist at all. Whatever options I use, @x always contains app/views/my/index.html.erb file content (even for existing controllers render_to_string ignore every parameter)
Comments and changes to this ticket
- 
         Pratik June 2nd, 2008 @ 12:18 PM- State changed from new to incomplete
 Use render_to_string :template => 'i_do_not_exists/index' What is the behavior in Rails 2.0.x ? 
- 
            
         Jaroslaw Zabiello June 2nd, 2008 @ 01:46 PMI do NOT want to render just another template (without its action). I want to render another action. I have just checked and I see it is broken for RoR 2.0.2 and 2.1.0 as well. Therefore information displayed in api.rubyonrails.org is misleading and wrong (capitalization is mine): render_to_string(options = nil, &block) Renders according to THE SAME RULES AS RENDER, but returns the result in a string instead of sending it as the response body to the browser.# app/views/controllers/my_controller.rb: class MyController < ApplicationController def index @slot = render_to_string :action => 'second' end def second @var = 'World' render :text => 'It will never be displayed from host/my!' end end # app/views/my/index.html.erb: Slot: <%= @slot %> # app/views/my/second.html.erb: Hello <%= @msg %>!Result at http://localhost:3000/my: Result: Slot: Hello !The @msg variable was not rendered at all. render :text was also ignored at all. It looks like render_to_string ignores Ruby code in the action. 
- 
         Pratik June 2nd, 2008 @ 01:49 PM- State changed from incomplete to invalid
 You cannot render another action. render_to_string is only for rendering templates. It will not call action code. 
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>
 Jaroslaw Zabiello
      Jaroslaw Zabiello
 Pratik
      Pratik