0

I am trying to add a new backend table to mobility gem enter link description here.

As mentioned enter link description here

You need to declare a new class and a new table. Here's my migration :

class CreateBooleanTranslations < ActiveRecord::Migration[6.1]
  def change
    create_table :mobility_boolean_translations do |t|
      t.string :locale, null: false
      t.string :key,    null: false
      t.boolean :value
      t.references :translatable, polymorphic: true, index: false
      t.timestamps null: false
    end
    add_index :mobility_text_translations, [:translatable_id, :translatable_type, :locale, :key], unique: true, name: :index_mobility_boolean_translations_on_keys
    add_index :mobility_text_translations, [:translatable_id, :translatable_type, :key], name: :index_mobility_boolean_translations_on_translatable_attribute
  end
end

I create a new class in app/lib/mobility/backends/active_record/boolean_translation.rb

module Mobility
  module Backends
    class ActiveRecord::KeyValue
      class BooleanTranslation < Translation
        self.table_name = "mobility_boolean_translations"
      end
    end
  end
end

then in my model, I add

translates :allow_publication_in_organizations_custom_catalog, type: :boolean

When I launch my app, I get :

You must define a Mobility::Backends::ActiveRecord::KeyValue::BooleanTranslation class.

Why do I get this error ? The class is actually defined.

David Geismar
  • 3,152
  • 6
  • 41
  • 80

0 Answers0