Serialize module for Typus, adds support for editing serialized data.
In your Gemfile
:
gem 'typus_serialize'
In your model:
class Profile < ActiveRecord::Base
typus_serialize :info, keys: %w(birthplace star_sign genre instrument url)
typus_serialize :music, keys: %w(title url)
typus_serialize :videos, keys: %w(title video_url poster_url)
...
limit
can be used to set how many instances of an attribute are allowed:
class Profile < ActiveRecord::Base
typus_serialize :info, keys: %w(birthplace star_sign genre instrument url), limit: 1
typus_serialize :music, keys: %w(title url), !ruby/range 1..6
typus_serialize :videos, keys: %w(title video_url poster_url), !ruby/range 0..4
...
typus_serialize
supports translatable attributes through the typus_translate
gem.
In your model:
class Profile < ActiveRecord::Base
typus_translate :bio, :info
typus_serialize :info, keys: %w(birthplace star_sign genre instrument url), limit: 1
In your typus.yml
:
Profile:
fields:
form: bio, info
Note: A field using typus_serialize
(e.g. info
) cannot be the first in a form.
A regular non-serialized field (e.g. bio
) must be used first to setup the translations.
This is a limitation that will be fixed in a future release.
Copyright (c) 2015 Wollzelle GmbH. See LICENSE for details.