Skip to content

Commit 0513b04

Browse files
authored
Merge pull request #23 from speee/fix/rails-8-forcessl-compatibility
Fix ActionController::ForceSSL compatibility with Rails 8.0+ (Issue JSONAPI-Resources#1477)
2 parents 302fa5d + 8aaa814 commit 0513b04

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

lib/jsonapi/resource_controller_metal.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22

33
module JSONAPI
44
class ResourceControllerMetal < ActionController::Metal
5+
# ActionController::ForceSSL was removed in Rails 8.0
6+
# It existed in Rails < 6.1, and force_ssl is now integrated into ActionController::Base
7+
FORCE_SSL_MODULE = if Gem::Requirement.new('< 6.1').satisfied_by?(ActionPack.gem_version)
8+
defined?(ActionController::ForceSSL) ? ActionController::ForceSSL : nil
9+
else
10+
nil
11+
end
12+
513
MODULES = [
614
AbstractController::Rendering,
715
ActionController::Rendering,
816
ActionController::Renderers::All,
917
ActionController::StrongParameters,
10-
Gem::Requirement.new('< 6.1').satisfied_by?(ActionPack.gem_version) ? ActionController::ForceSSL : nil,
18+
FORCE_SSL_MODULE,
1119
ActionController::Instrumentation,
1220
JSONAPI::ActsAsResourceController
1321
].compact.freeze

0 commit comments

Comments
 (0)