Sha256: 1b40343c9df67f2a58f980d724f12ad703e3aaf54222e6f0e4e0b358ee90123c
Contents?: true
Size: 647 Bytes
Versions: 2
Compression:
Stored size: 647 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.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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spina-2.12.0 | app/models/concerns/spina/translated_content.rb |
spina-2.11.0 | app/models/concerns/spina/translated_content.rb |