Get output of different controller action in rails3
For generating PDF from HTML, i need to fill a variable with output from another controller action output (HTML). Is there any 开发者_Python百科elegant way, how to get this HTML?
Thanks
You can use:
def print
output = render_to_string(:action => :index)
end
in your controller.
You may abstract the code in that action into a shared method which would be called within your pdf-generating action.
After calling the shared method, you would get the html page content like this:
pdf_content = ERB.new(File.read("/path/to/that/erb.file")).result
精彩评论