mirror of
https://github.com/ditkrg/active_model_serializers.git
synced 2026-01-25 07:16:49 +00:00
Move caching initialization to Railtie
Also - Add reference to config from ActiveModelSerializers.config - correctly call super in FragmentCacheTest#setup - rename test rails app from Foo to ActiveModelSerializers::RailsApplication
This commit is contained in:
@@ -152,7 +152,7 @@ module ActiveModel
|
||||
# @todo require less code comments. See
|
||||
# https://github.com/rails-api/active_model_serializers/pull/1249#issuecomment-146567837
|
||||
def self.cache(options = {})
|
||||
self._cache = ActionController::Base.cache_store if Rails.configuration.action_controller.perform_caching
|
||||
self._cache = ActiveModelSerializers.config.cache_store if ActiveModelSerializers.config.perform_caching
|
||||
self._cache_key = options.delete(:key)
|
||||
self._cache_only = options.delete(:only)
|
||||
self._cache_except = options.delete(:except)
|
||||
|
||||
@@ -8,6 +8,13 @@ module ActiveModel
|
||||
end
|
||||
end
|
||||
|
||||
initializer 'active_model_serializers.caching' do
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
ActiveModelSerializers.config.cache_store = ActionController::Base.cache_store
|
||||
ActiveModelSerializers.config.perform_caching = Rails.configuration.action_controller.perform_caching
|
||||
end
|
||||
end
|
||||
|
||||
initializer 'generators' do |app|
|
||||
app.load_generators
|
||||
require 'generators/serializer/resource_override'
|
||||
|
||||
Reference in New Issue
Block a user