@@ -11,25 +11,15 @@ class Railtie < Rails::Railtie
11
11
12
12
initializer 'active_model_serializers.action_controller' do
13
13
ActiveSupport . on_load ( :action_controller ) do
14
- ActionController :: Base . send ( : include, ::ActionController ::Serialization )
14
+ include ( ::ActionController ::Serialization )
15
15
end
16
16
end
17
17
18
- initializer 'active_model_serializers.logger' , :after => 'action_controller.set_configs' do
18
+ # This hook is run after the action_controller railtie has set the configuration
19
+ # based on the *environment* configuration and before any config/initializers are run
20
+ # and also before eager_loading (if enabled).
21
+ initializer 'active_model_serializers.set_configs' , :after => 'action_controller.set_configs' do
19
22
ActiveModelSerializers . logger = Rails . configuration . action_controller . logger
20
- end
21
-
22
- # To be useful, this hook must run after Rails has initialized,
23
- # BUT before any serializers are loaded.
24
- # Otherwise, the call to 'cache' won't find `cache_store` or `perform_caching`
25
- # defined, and serializer's `_cache_store` will be nil.
26
- # IF the load order cannot be changed, then in each serializer that that defines a `cache`,
27
- # manually specify e.g. `PostSerializer._cache_store = Rails.cache` any time
28
- # before the serializer is used. (Even though `ActiveModel::Serializer._cache_store` is
29
- # inheritable, we don't want to set it on `ActiveModel::Serializer` directly unless
30
- # we want *every* serializer to be considered cacheable, regardless of specifying
31
- # `cache # some options` in a serializer or not.
32
- initializer 'active_model_serializers.caching' , :after => 'action_controller.set_configs' do
33
23
ActiveModelSerializers . config . cache_store = Rails . configuration . action_controller . cache_store
34
24
ActiveModelSerializers . config . perform_caching = Rails . configuration . action_controller . perform_caching
35
25
end
0 commit comments