Run controller filter to activate_draper
as early as possible
#721
Labels
Milestone
activate_draper
as early as possible
#721
Fixes #640
I haven't figured out how to fix this deterministically in the Draper code, yet, but here's a breakdown of the issue and the fix, so hopefully someone can make a PR.
This is on Draper 2.1.0, Rails 4.2.5.1, Ruby 2.2.
/users/sign_in
we were gettinga
NoMethodError
undefined method 'host' for nil:NilClass
h.request
was returning nilcontroller
is set in a waythat mocks the controller and request when
Draper::ViewContext.controller is nil.
Draper::ViewContext.controller || ApplicationController.new
. https://github.com/drapergem/draper/blob/v2.1.0/lib/draper/view_context/build_strategy.rb#L39-L42Draper::ViewContext.controller
is set in the controller by thecallback
before_filter :activate_draper
https://github.com/drapergem/draper/blob/v2.1.0/lib/draper.rb#L36before_action
filters that 1) use draper and2) run before the
active_draper
callback won't have the controllercontext set
The specific callbacks we had running was
Devise::SessionController#after_sign_in_path_for
and the code fix was:where the
UserDecorator#sign_in_path
was callingh.rails_admin.dashboard_path
.I tried futzing with changing the Draper filter to
prepend_before_action :activate_draper
, but that didn't work, so I went with the fix above and made this issue :)It's possible we may want to modify the initializer to run earlier via
:after => 'action_controller.set_configs'
as below, but I haven't tried it.The text was updated successfully, but these errors were encountered: