diff --git a/app/models/web/page.rb b/app/models/web/page.rb index d3927936..cdfd0da7 100644 --- a/app/models/web/page.rb +++ b/app/models/web/page.rb @@ -20,6 +20,8 @@ def self.null_object # @param name [String] # @return [Web::Page] def self.by_slug(slug) + return find_by(slug: slug.to_s)&.first if Rails.env.production? + fetch_or_store to_key(slug) do find_by(slug: slug.to_s)&.first end diff --git a/app/models/web/resource.rb b/app/models/web/resource.rb index c52e0d4f..aa8f81f9 100644 --- a/app/models/web/resource.rb +++ b/app/models/web/resource.rb @@ -9,16 +9,11 @@ class Resource < ContentfulModel::Base # @param name [String] # @return [Web::Resource] def self.by_name(name) + return find_by(name: name.to_s).first if Rails.env.production? + fetch_or_store to_key(name) do find_by(name: name.to_s).first end end - - # @return [Array