module Caffeine
  module Concerns
    module SeoFriendly
      extend ActiveSupport::Concern

      included do
        if defined?(::ActsAsSeoFriendly)
          acts_as_seo_friendly

          after_initialize :build_seo_datum, if: ->(obj) { obj.seo_datum.blank? }

          self.permitted_attributes << { seo_datum_attributes: ::ActsAsSeoFriendly::SeoDatum::PERMITTED_ATTRIBUTES }
        end
      end
    end
  end
end

module Caffeine
  module Concerns
    module SeoFriendly
      extend ActiveSupport::Concern

      included do
        if defined?(::ActsAsSeoFriendly)
          acts_as_seo_friendly

          after_initialize :build_seo_datum, if: ->(obj) { obj.seo_datum.blank? }

          accepts_nested_attributes_for :seo_datum
          
          self.permitted_attributes << { seo_datum_attributes: ::ActsAsSeoFriendly::SeoDatum::PERMITTED_ATTRIBUTES }
        end
      end
    end
  end
end

Allow accepting nested attributes for seo_datum
Allow accepting nested attributes for seo_datum