Also initialize ViewContext for rails runner (#739)

Initialize Draper's ViewContext when using the runner command in a
similar way to using the console command. Without this code run by the
rails runner command (e.g. when processing commands from a message
queue) will not have a properly initialized ViewContext, and
consequently the helpers will not be initialized.
This commit is contained in:
Hans de Graaff 2017-03-29 17:30:43 +02:00 committed by Cliff Braton
parent bc222f5dc7
commit 2e6f741a63
1 changed files with 6 additions and 0 deletions

View File

@ -55,6 +55,12 @@ module Draper
Draper::ViewContext.build
end
runner do
require 'action_controller/test_case'
ApplicationController.new.view_context
Draper::ViewContext.build
end
rake_tasks do
Dir[File.join(File.dirname(__FILE__),'tasks/*.rake')].each { |f| load f }
end