diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index eeaf6a7ff..801bb8e16 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -46,8 +46,8 @@ module ApplicationHelper end end - def content_block(name, locale = I18n.locale) - SiteCustomization::ContentBlock.block_for(name, locale) + def content_block(...) + SiteCustomization::ContentBlock.block_for(...) end def self.asset_data_base64(path) diff --git a/app/models/site_customization/content_block.rb b/app/models/site_customization/content_block.rb index a7e95d0ab..6009505b7 100644 --- a/app/models/site_customization/content_block.rb +++ b/app/models/site_customization/content_block.rb @@ -4,8 +4,7 @@ class SiteCustomization::ContentBlock < ApplicationRecord validates :locale, presence: true, inclusion: { in: ->(*) { Setting.enabled_locales.map(&:to_s) }} validates :name, presence: true, uniqueness: { scope: :locale }, inclusion: { in: ->(*) { VALID_BLOCKS }} - def self.block_for(name, locale) - locale ||= I18n.default_locale + def self.block_for(name, locale = I18n.locale) find_by(name: name, locale: locale)&.body end end