Rails 3.1 render_to_string returns an empty string

from the controller method, I am trying to grab the template rendering output from another controller.

view file is here:

path/to/show.html.erb

in my controller i:

def create
  html_string = render_to_string :template => 'path/to/show'
  raise 'html string is empty!' if html_string.empty?
  # do some other stuff
end

The view file is very simple, just containing the text "foo".

I am not getting any error regarding the fact that the rails cannot find the show.html.erb file, but the html_string is empty and an error occurs.

I see this behavior when running the create method using the rspec controller test. I have not tried the code through the rails server yet.

Does anyone see something I'm missing here?

+5
source share
2 answers

- , :

render_views
+14

describe UsersController do
 integrate_views
0

All Articles