Created
June 8, 2012 23:38
-
-
Save jch/2898697 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
# A Sidekiq background job worker tha knows how to render Rails views | |
# Don't worry, I *think* I know what I'm doing ;) | |
class RenderWorker < AbstractController::Base | |
include AbstractController::Rendering | |
include AbstractController::Logger # dependency from actionview calling logging | |
include Rails.application.routes.url_helpers | |
include Sidekiq::Worker | |
append_view_path "#{Rails.root}/app/views" # from AbstractController::ViewPaths | |
def perform | |
@somevar = "somevalue" # variables and route helpers available in view | |
html = render :action => 'foo' | |
Pusher['some_channel'].trigger('some_event', html) | |
end | |
end | |
w = RenderWorker.new | |
w.perform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how did this code work out for you?