Mobility 是否有可能扩展数据类型以实现移动性

Mobility 是否有可能扩展数据类型以实现移动性,mobility,Mobility,我喜欢gem及其工作原理,我只是想知道是否有任何现有的或计划中的功能来指定翻译的数据类型,而不是text和string(存储在mobility\uu[type]\u translations)?这没有文档记录,但支持Integer、Float、,等等 e、 g.对于Integer,您必须创建如下表: create_table "mobility_integer_translations", force: :cascade do |t| t.string "

我喜欢gem及其工作原理,我只是想知道是否有任何现有的或计划中的功能来指定翻译的数据类型,而不是
text
string
(存储在
mobility\uu[type]\u translations
)?

这没有文档记录,但支持Integer、Float、,等等

e、 g.对于Integer,您必须创建如下表:

  create_table "mobility_integer_translations", force: :cascade do |t|
    t.string "locale", null: false
    t.string "key", null: false
    t.integer "value"
    t.string "translatable_type"
    t.bigint "translatable_id"
    t.datetime "created_at", precision: 6, null: false
    t.datetime "updated_at", precision: 6, null: false
    t.index ["translatable_id", "translatable_type", "key"], name: "index_mobility_string_translations_on_translatable_attribute"
    t.index ["translatable_id", "translatable_type", "locale", "key"], name: "index_mobility_string_translations_on_keys", unique: true
    t.index ["translatable_type", "key", "value", "locale"], name: "index_mobility_string_translations_on_query_keys"
  end
然后需要为此表创建一个类:

module Mobility
  module Backends
    class ActiveRecord::KeyValue
      class IntegerTranslation < Translation
        self.table_name = "mobility_integer_translations"
      end
    end
  end
end

Mobility本身并没有说您不能使用其他翻译类,只是这些不是现成的。也许这应该添加到Wiki的某个地方。

ooh,这是一个相当不错的解决方案!
translates :foo, type: :integer