Return view later through delayed_job

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/

+4
source share
1 answer

check this question, it contains the code that is probably needed in the answer:

Rails 3> Displaying Views in a Graded Task

+1
source

Source: https://habr.com/ru/post/1484927/


All Articles