If I create html, I get html in a browser that works fine. However, how can I get a route response (html) when called in a module or class.
I need to do this because I am sending documents to DocRaptor and instead of storing markup / html in the db column, I would like to instead store the record IDs and create markup when the job is done.
A possible solution is to use the Ruby HTTP library, Httparty or wget or something else, open the route and use response.body. Before doing this, I thought I'd ask.
Thanks!
- Update -
Here's something like what I ended up with:
Quick tip - in case someone does this and needs their helper methods, you need to extend AV using ApplicationHelper:
Here's something like what I ended up with:
av = ActionView::Base.new() av.view_paths = ActionController::Base.view_paths av.extend ApplicationHelper #or any other helpers your template may need body = av.render(:template => "orders/receipt.html.erb",:locals => {:order => order})
Link: http://www.rigelgroupllc.com/blog/2011/09/22/render-rails3-views-outside-of-your-controllers/
source share