@@ -16,25 +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
- if JSONAPI ::Rails . config . extend_action_controller
22
- include ::JSONAPI ::Rails ::Controller
23
- end
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
24
23
25
- if JSONAPI ::Rails . config . register_mime_type
26
- 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
27
29
end
30
+ end
28
31
29
- if JSONAPI ::Rails . config . register_parameter_parser
30
- if ::Rails ::VERSION ::MAJOR >= 5
31
- ::ActionDispatch ::Request . parameter_parsers [ :jsonapi ] = PARSER
32
- else
33
- ::ActionDispatch ::ParamsParser ::DEFAULT_PARSERS [ Mime [ :jsonapi ] ] = PARSER
34
- end
32
+ if JSONAPI ::Rails . config . extend_action_controller
33
+ ActiveSupport . on_load ( :action_controller ) do
34
+ include ::JSONAPI ::Rails ::Controller
35
35
end
36
+ end
36
37
37
- if JSONAPI ::Rails . config . register_renderers
38
+ if JSONAPI ::Rails . config . register_renderers
39
+ ActiveSupport . on_load ( :action_controller ) do
38
40
RENDERERS . each do |name , renderer |
39
41
::ActionController ::Renderers . add ( name ) do |resources , options |
40
42
# Renderer proc is evaluated in the controller context.
0 commit comments