How do I render a partial to a string from within a filter attached to a controller
- by Tristan Havelick
I have some code I need to use in multiple controllers in a rails 1.0 application (I can't, for strange reasons upgrade to a newer rails). I've extracted the relevant code into a filer object, and I'm using the around_filter construct to execute it.
Before the extract, I was using the method render_to_string() to get the contents of a rendered partial into a string. However, this method is protected, so I am unable to access it from within my Filter object. As a workaround, I tried adding this to my ApplicationController:
def render_to_string(*a)
super(*a)
end
this seems to have remedied the protection level issue, but now I get the error:
Can only render or redirect once per action
When no such error occurred before the extraction. Why? Is there a different approach I should take here?