shioyama/mobility

The presence plugin doesn't work as expected

KonstantinReido opened this issue · 1 comments

Context

  • rails (5.2.8.1)
  • mobility (1.2.9)
  • Postgres

My config file:

Mobility.configure do
  plugins do
    backend :key_value, type: :string
    active_record
    reader
    writer
    backend_reader
    query
    cache
    fallbacks({ :"en-GB" => :"nb-NO" })
    presence
    locale_accessors
    dirty
  end
end

Expected Behavior

After adding the plugin to the config by default it applies to all translations.

Actual Behavior

I need to write presence: true to each translation to make it work

Steps to reproduce

Activate the plugin in the config, then do the next steps:

  1. Store a value to a translation.
  2. Try to change the translation on an empty string.
  3. In DB old record was deleted and a new one was created with nil in the value column
  4. Try again to store an empty string for the translation
  5. At this time record with nil in the value column deleted

If on a model level for each translation, I define presence: true, then it works as expected.

You need to provide a reproducible example for your problem. The presence plugin has been around for years and there are specs checking that it works, so it's very unlikely that there is an issue. More likely it's some kind of compatibility issue or you are not understanding how it works.