@@ -16,23 +16,27 @@ class Railtie < ::Rails::Railtie
16
16
jsonapi_error : ErrorsRenderer . new
17
17
} . freeze
18
18
19
- initializer 'jsonapi-rails.action_controller' do
20
- ActiveSupport . on_load ( :action_controller ) do
21
- include ::JSONAPI ::Rails ::Controller
19
+ initializer 'jsonapi.init' , after : :load_config_initializers do
20
+ if JSONAPI ::Rails . config . register_mime_type
21
+ Mime ::Type . register MEDIA_TYPE , :jsonapi
22
+ end
22
23
23
- if JSONAPI ::Rails . config . register_mime_type
24
- Mime ::Type . register MEDIA_TYPE , :jsonapi
24
+ if JSONAPI ::Rails . config . register_parameter_parser
25
+ if ::Rails ::VERSION ::MAJOR >= 5
26
+ ::ActionDispatch ::Request . parameter_parsers [ :jsonapi ] = PARSER
27
+ else
28
+ ::ActionDispatch ::ParamsParser ::DEFAULT_PARSERS [ Mime [ :jsonapi ] ] = PARSER
25
29
end
30
+ end
26
31
27
- if JSONAPI ::Rails . config . register_parameter_parser
28
- if ::Rails ::VERSION ::MAJOR >= 5
29
- ::ActionDispatch ::Request . parameter_parsers [ :jsonapi ] = PARSER
30
- else
31
- ::ActionDispatch ::ParamsParser ::DEFAULT_PARSERS [ Mime [ :jsonapi ] ] = PARSER
32
- end
32
+ if JSONAPI ::Rails . config . extend_action_controller
33
+ ActiveSupport . on_load ( :action_controller ) do
34
+ include ::JSONAPI ::Rails ::Controller
33
35
end
36
+ end
34
37
35
- if JSONAPI ::Rails . config . register_renderers
38
+ if JSONAPI ::Rails . config . register_renderers
39
+ ActiveSupport . on_load ( :action_controller ) do
36
40
RENDERERS . each do |name , renderer |
37
41
::ActionController ::Renderers . add ( name ) do |resources , options |
38
42
# Renderer proc is evaluated in the controller context.
0 commit comments