Skip to content

Commit

Permalink
Add Rails 5 API support
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Nov 20, 2017
1 parent e88a267 commit 5ae12b0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/cancan/controller_additions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,12 @@ def cannot?(*args)
end
end

if defined? ActionController
%w[Base API].each do |klass|
next unless ActionController.const_defined?(klass)
ActionController.const_get(klass).class_eval { include CanCan::ControllerAdditions }
if defined? ActionController::Base
ActionController::Base.class_eval do
include CanCan::ControllerAdditions
end
elsif defined? ActionController::API
ActionController::API.class_eval do
include CanCan::ControllerAdditions
end
end

0 comments on commit 5ae12b0

Please sign in to comment.