Ran across this today using render_to_string along with a normal render:
def some_action begin @cache = render_to_string(:file => self.find_some_file) rescue ActionController::MissingTemplate => e logger.debug("file not found, eating exception and continuing...") end @posts = Post.find... # other stuff here, normal processing, etc render end
The problem is that if render_to_string throws an exception, it never does forget_variables_added_to_assigns and reset_variables_added_to_assigns (see render_to_string source in ActionController::Base). So @variables_added will equal true, and future instance variables won't be added to assigns, and so of course won't be available in the view. Thats bad.
I'm guessing render_to_string is often used in cases like this, where you just want to grab some static file and its possible the file is missing. So it seems it should handle the exception gracefully and reset the variables added to assigns, so later processing in the action works.
Does this make sense? Should I submit a patch to handle this correctly?
btw this is against 1.1.6. but from looking at edge it looks like the same thing would happen. - Rob