Sha256: e6ccc8ae309d5dc5edfc1bc72080389017ef2c29cd24984855dbf09fcb43ac5a
Contents?: true
Size: 654 Bytes
Versions: 20
Compression:
Stored size: 654 Bytes
Contents
module Spina module TranslatedContent extend ActiveSupport::Concern include Spina::AttrJsonMonkeypatch included do # Store each locale's content in [locale]_content as an array of parts Spina.config.locales.each do |locale| attr_json "#{locale}_content".to_sym, AttrJson::Type::SpinaPartsModel.new, array: true, default: -> { [] } attr_json_setter_monkeypatch "#{locale}_content".to_sym attr_json_accepts_nested_attributes_for "#{locale}_content".to_sym end end def find_part(name) send("#{I18n.locale}_content").find{|part| part.name.to_s == name.to_s} end end end
Version data entries
20 entries across 20 versions & 1 rubygems