Created
January 24, 2014 17:58
-
-
Save jackrg/8602584 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SalesReportWorker < ApplicationController | |
include Sidekiq::Worker | |
sidekiq_options backtrace: true, retry: false | |
self.view_paths = "app/views" # Where to look for view templates | |
def perform(request_ident, params) | |
@_response = ActionDispatch::Response.new # Needed to avoid "ActionController::RackDelegation#content_type | |
# delegated to @_response.content_type, but @_response is nil" error | |
... | |
html = render template: 'sales_reports/show.js.erb' | |
... | |
end | |
... | |
end |
Hello, Jack. Did you try this approach on Rails 4.1? I'm trying to do this, but I'm getting the following error:
Failure/Error: subject.export
ActionView::Template::Error:
undefined method 'host' for nil:NilClass
Do you have any idea? Rails expect to find a request
object that responds to host
method. The backtrace: actionpack-4.1.9/lib/action_controller/metal/url_for.rb:27:in
url_options'`
Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This gist shows how to use the Rails rendering engine within a Sidekiq worker.