diff --git a/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb b/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb index 53330fd7..1e4555df 100644 --- a/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb +++ b/wcc-contentful-app/app/controllers/wcc/contentful/app/pages_controller.rb @@ -46,10 +46,16 @@ def redirect_model WCC::Contentful::Model.resolve_constant('redirect') end - def global_site_config + def site_config_model # They may have not installed `site-config` in the project - return unless defined?(WCC::Contentful::Model::SiteConfig) + WCC::Contentful::Model.resolve_constant('site-config') + rescue WCC::Contentful::ContentTypeNotFoundError + nil + end + + def global_site_config + return unless model = site_config_model - @global_site_config ||= WCC::Contentful::Model::SiteConfig.instance(preview?) + @global_site_config ||= model.instance(preview?) end end diff --git a/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb b/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb index a30e83cb..13b3da33 100644 --- a/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb +++ b/wcc-contentful/spec/wcc/contentful/store/lazy_cache_store_spec.rb @@ -224,7 +224,7 @@ .times(2) # act - main_menu = store.find_all(content_type: 'menu') + store.find_all(content_type: 'menu') .apply(name: 'Main Menu') .first end