Cannot use the `append_content_security_policy_directives` method in `ApplicationController`
The append_content_security_policy_directives from SecureHeaders can be referenced in ApplicationController as follows:
class ApplicationController < ActionController::Base
def foo
append_content_security_policy_directives(xxxx)
end
end
However, Sorbet seems unable to find append_content_security_policy_directives.
Method
append_content_security_policy_directivesdoes not exist onApplicationController
By the way, the method is generated in RBI as follows:
# sorbet/rbi/gems/[email protected]
module SecureHeaders
def append_content_security_policy_directives(additions); end
# ...
end
Therefore, it's possible that ActionController and SecureHeaders are not linked correctly.
Looks like SecureHeaders is mixed in using ActiveSupport.on_load here. DynamicMixin compiler doesn't see this include and therefore doesn't reflect the dynamic mixin in the RBI.
Instead, you can define a shim in sorbet/rbi/shims/secure_headers.rbi that contains something like this to resolve the error:
class ActionController::Base
include SecureHeaders
end
Further investigation is needed to see exactly why the DynamicMixin compiler isn't picking this up.
Thank you for the details. As you said, I'm addressing this by placing the exact same RBI in sorbet/rbi/shims/secure_headers.rbi.