Skip to content

Commit 3877644

Browse files
author
Shane Boyer
committed
Restore support for Rails 4.x using rails-api
1 parent 45e6068 commit 3877644

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/api-pagination/hooks.rb

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
begin; require 'rails'; rescue LoadError; end
22
begin; require 'rails-api'; rescue LoadError; end
3+
34
if defined?(Rails)
5+
module ApiPagination
6+
module Hooks
7+
def self.rails_parent_controller
8+
if Gem::Version.new(Rails.version) >= Gem::Version.new('5') || defined?(ActionController::API)
9+
ActionController::API
10+
else
11+
ActionController::Base
12+
end
13+
end
14+
end
15+
end
16+
417
require 'rails/pagination'
518

619
ActiveSupport.on_load(:action_controller) do
@@ -27,14 +40,3 @@
2740
WARNING
2841
end
2942

30-
module ApiPagination
31-
module Hooks
32-
def self.rails_parent_controller
33-
if Gem::Version.new(Rails.version) >= Gem::Version.new('5') || defined?(ActionController::API)
34-
ActionController::API
35-
else
36-
ActionController::Base
37-
end
38-
end
39-
end
40-
end

0 commit comments

Comments
 (0)