Skip to content

Commit

Permalink
Support injecting helpers into ActionController::API (#133)
Browse files Browse the repository at this point in the history
Rails API apps use the lighter alternative to ActionController::Base.
This adds support for injecting these helpers into either action
controller base class that the consuming application happens to inherit
from.
  • Loading branch information
andrewhood125 authored and Ch4s3 committed Jul 9, 2018
1 parent cc18629 commit 2fea1d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/sorcery/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ class Engine < Rails::Engine
config.sorcery = ::Sorcery::Controller::Config

initializer 'extend Controller with sorcery' do
ActionController::Base.send(:include, Sorcery::Controller)
ActionController::Base.helper_method :current_user
ActionController::Base.helper_method :logged_in?
ActiveSupport.on_load('action_controller') do
send(:include, Sorcery::Controller)
helper_method :current_user
helper_method :logged_in?
end
end
end
end

0 comments on commit 2fea1d7

Please sign in to comment.