开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜