How column_fallback works?

136 Views Asked by At

How does column_fallback work?

I've added the line column_fallback to the initializer and set in the model something like:

  extend Mobility
  translates :title, type: :string, column_fallback: true
[2] pry(main)> b.title
=> "Ecologia política"
[3] pry(main)> Mobility.locale = :en
=> :en
[4] pry(main)> b.title
  Mobility::Backends::ActiveRecord::KeyValue::StringTranslation Load (0.3ms)  SELECT "mobility_string_translations".* FROM "mobility_string_translations" WHERE "mobility_string_translations"."translatable_type" = $1 AND "mobility_string_translations"."key" = $2 AND "mobility_string_translations"."translatable_id" = $3  [["translatable_type", "Blox"], ["key", "title"], ["translatable_id", 21342]]
=> nil
1

There are 1 best solutions below

0
Trinculo On

In config/initializers/mobility.rb inside the Mobility.configure block add:

column_fallback true