shioyama / mobility

Pluggable Ruby translation framework
MIT License
1k stars 82 forks source link

Activating Mobility in a model generates ActiveRecord::NotNullViolation #651

Open crow-rojas opened 4 days ago

crow-rojas commented 4 days ago

Hi, Im setting up Mobility in our Rails app. It works when working in the console setting and saving data. But a problem appeared when we ran all our test suite. Consider a model called "General", we have a test helper that helps us to create one instance of this model with:

General.find_or_initialize_by(nombre: nombre).update!(valor: valor.to_s)

This helper fails in the update! method execution. I was debugging activerecord and ocurrs specifically in the save! internal execution of Rails. This is the full error:

    PG::NotNullViolation: ERROR:  null value in column "valor" of relation "generals" violates not-null constraint
DETAIL:  Failing row contains (992314608, 2024-10-15 18:18:44.388633, doble_trabajo, 2024-10-15 18:18:44.388633, null).

I tried different configurations of Mobility and in the model but nothing works :( These are the files currently:

General model ```ruby # frozen_string_literal: true # == Schema Information # # Table name: generals # # created_at :datetime not null # id :integer not null, primary key # nombre :string not null # updated_at :datetime not null # valor :string not null # # Indexes # # general_unique_name (nombre) UNIQUE # class General < ApplicationRecord # rubocop:disable Metrics/ClassLength extend Mobility translates :valor, type: :string # MODOS DE MANTENIMIENTO MAINTENANCE_MODES = ['starter_enterprise'].freeze CACHE_KEY = "General.generales_hash" has_paper_trail meta: nil validates :nombre, uniqueness: true validates :valor, presence: true, if: proc{ valor.nil? } # permitimos string vacio pero no nil validate :validate_activar_agrupacion_items_descripcion validate :validar_traduccion_employee_no_vacia validate :validar_traduccion_employee_sin_espacios validate :validar_traduccion_recintos_no_vacia validate :validar_traduccion_empresa_no_vacia validate :validar_traduccion_empresa_sin_espacios validate :validar_traduccion_empresa_limite_veinticinco_caracteres validate :validar_activar_autogeneracion_codigo_de_ficha_importadores validate :validar_empresa_nomina_transfer_agrupada_por_banco before_save :set_permissions #TODO: Eliminar en el feature before_save :set_value_agrupacion before_save :set_value_autogeneracion_codigo_de_ficha_importadores before_save :deactivate_normal_user_amonestaciones before_save :activate_sso_config_on_asistencia after_commit { General.recargar } ... ```
Mobility Config ```ruby Mobility.configure do # PLUGINS plugins do # Backend # # Sets the default backend to use in models. This can be overridden in models # by passing +backend: ...+ to +translates+. # # To default to a different backend globally, replace +:key_value+ by another # backend name. # backend :key_value # ActiveRecord # # Defines ActiveRecord as ORM, and enables ActiveRecord-specific plugins. active_record # Accessors # # Define reader and writer methods for translated attributes. Remove either # to disable globally, or pass +reader: false+ or +writer: false+ to # +translates+ in any translated model. # reader writer # Backend Reader # # Defines reader to access the backend for any attribute, of the form # +_backend+. # backend_reader # # Or pass an interpolation string to define a different pattern: # backend_reader "%s_translations" # Query # # Defines a scope on the model class which allows querying on # translated attributes. The default scope is named +i18n+, pass a different # name as default to change the global default, or to +translates+ in any # model to change it for that model alone. # query # Cache # # Comment out to disable caching reads and writes. # cache # Dirty # # Uncomment this line to include and enable globally: # dirty # # Or uncomment this line to include but disable by default, and only enable # per model by passing +dirty: true+ to +translates+. # dirty false # Column Fallback # # Uncomment line below to fallback to original column. You can pass # +column_fallback: true+ to +translates+ to return original column on # default locale, or pass +column_fallback: [:en, :de]+ to +translates+ # to return original column for those locales or pass # +column_fallback: ->(locale) { ... }+ to +translates to evaluate which # locales to return original column for. # column_fallback # # Or uncomment this line to enable column fallback with a global default. column_fallback true # Fallbacks # # Uncomment line below to enable fallbacks, using +I18n.fallbacks+. # fallbacks # # Or uncomment this line to enable fallbacks with a global default. fallbacks [{ "es-cl" => "es", "es-co" => "es", "es-pe" => "es", "es-mx" => "es", "es-br" => "es", "en-cl" => "en", "en-co" => "en", "en-pe" => "en", "en-mx" => "en", "en-br" => "en", "pt-cl" => "pt", "pt-co" => "pt", "pt-pe" => "pt", "pt-mx" => "pt", "pt-br" => "pt", }] # Presence # # Converts blank strings to nil on reads and writes. Comment out to # disable. # presence # Default # # Set a default translation per attributes. When enabled, passing +default: # 'foo'+ sets a default translation string to show in case no translation is # present. Can also be passed a proc. # # default # Fallthrough Accessors # # Uses method_missing to define locale-specific accessor methods like # +title_en+, +title_en=+, +title_fr+, +title_fr=+ for each translated # attribute. If you know what set of locales you want to support, it's # generally better to use Locale Accessors (or both together) since # +method_missing+ is very slow. (You can use both fallthrough and locale # accessor plugins together without conflict.) # fallthrough_accessors # Locale Accessors # # Uses +def+ to define accessor methods for a set of locales. By default uses # +I18n.available_locales+, but you can pass the set of locales with # +translates+ and/or set a global default here. # # locale_accessors # # Or define specific defaults by uncommenting line below locale_accessors [ "es", "es-cl", "es-co", "es-pe", "es-mx", "es-br", "en", "en-cl", "en-co", "en-pe", "en-mx", "en-br", "pt", "pt-cl", "pt-co", "pt-pe", "pt-mx", "pt-br", ] # Attribute Methods # # Adds translated attributes to +attributes+ hash, and defines methods # +translated_attributes+ and +untranslated_attributes+ which return hashes # with translated and untranslated attributes, respectively. Be aware that # this plugin can create conflicts with other gems. # # attribute_methods end end ```

Context

Gemfile.lock ```ruby GIT remote: https://github.com/Chetane/fixy revision: ae8324003101c6da2759372286bf0606649da54b ref: ae8324003101c6da2759372286bf0606649da54b specs: fixy (0.0.8) rake GIT remote: https://github.com/bukhr/data_uri.git revision: 374a8463da08f6a9bf50caf4e1cd64985fa17f5e specs: data_uri (0.1.0) GIT remote: https://github.com/bukhr/eav_hashes.git revision: 46e1bebd1acca278e8d39675c6c3776ce1b47ddf specs: eav_hashes (1.1.0) rails (>= 3.2.7) GIT remote: https://github.com/bukhr/i18n-recursive-lookup.git revision: 8d859521092d351aab43613ef11ec15802d671f3 specs: i18n-recursive-lookup (0.0.6) activesupport i18n GIT remote: https://github.com/bukhr/omniauth-office365.git revision: 430e9f70f573332223693f16b127d028025a064e specs: omniauth-office365 (1.2.0) omniauth-oauth2 (~> 1.7.1) GIT remote: https://github.com/bukhr/plaintext.git revision: 872944b5fbf88cf64e8d82bf6bdf91319bf0cd72 specs: plaintext (0.3.3) activesupport (> 2.2.1) nokogiri (~> 1.10, >= 1.10.4) rubyzip (~> 2.0.0) GIT remote: https://github.com/bukhr/ruby-lsp-i18n.git revision: a790a4b016e8da0c1f97aa5e16a4f510d8c0ccc5 ref: a790a4b016e8da0c1f97aa5e16a4f510d8c0ccc5 specs: ruby-lsp-i18n (0.2.1) ruby-lsp (~> 0.17.17, < 0.18.0) GIT remote: https://github.com/bukhr/traceroute.git revision: 3cb4909eee619ca89865661c32947b98844d99e6 specs: traceroute (0.8.1) rails (>= 3.0.0) GIT remote: https://github.com/sqlhabit/twemoji.git revision: a5ac73a09db530f35fcb1f61620ea2e4c0d1d8ee tag: v4.0.1 specs: twemoji (4.0.0) nokogiri (~> 1.6) PATH remote: gems/automation specs: automation (0.1.0) discard pg rails (>= 6.0.5) PATH remote: gems/boost_api specs: boost_api (0.1.0) rest-client (~> 2.1) PATH remote: gems/buk_extract_i18n specs: buk_extract_i18n (1.0.0) better_html diff-lcs diffy nokogiri parser (>= 2.6) ruby-openai tty-prompt zeitwerk PATH remote: gems/country_sti specs: country_sti (0.1.0) rails (>= 6.0.5) PATH remote: gems/ensure_gem_version specs: ensure_gem_version (0.1.0) PATH remote: gems/prometheus_integration specs: prometheus_integration (0.1.0) prometheus_exporter (~> 2.0) rails (>= 6.0.5) PATH remote: gems/rails_workflow specs: rails_workflow (0.7.1) draper guid kaminari rails (>= 4.1.0) PATH remote: gems/rubocop-buk specs: rubocop-buk (0.1.0) rubocop PATH remote: gems/yard-buk specs: yard-buk (0.1.0) PATH remote: packs/plataforma/building_blocks/fiji specs: fiji (0.1.0) GEM remote: https://rubygems.org/ specs: abstract_notifier (0.3.2) ace-rails-ap (4.2) actioncable (6.1.7.8) actionpack (= 6.1.7.8) activesupport (= 6.1.7.8) nio4r (~> 2.0) websocket-driver (>= 0.6.1) actionmailbox (6.1.7.8) actionpack (= 6.1.7.8) activejob (= 6.1.7.8) activerecord (= 6.1.7.8) activestorage (= 6.1.7.8) activesupport (= 6.1.7.8) mail (>= 2.7.1) actionmailer (6.1.7.8) actionpack (= 6.1.7.8) actionview (= 6.1.7.8) activejob (= 6.1.7.8) activesupport (= 6.1.7.8) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) actionpack (6.1.7.8) actionview (= 6.1.7.8) activesupport (= 6.1.7.8) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) actiontext (6.1.7.8) actionpack (= 6.1.7.8) activerecord (= 6.1.7.8) activestorage (= 6.1.7.8) activesupport (= 6.1.7.8) nokogiri (>= 1.8.5) actionview (6.1.7.8) activesupport (= 6.1.7.8) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) active-record-query-count (0.1.4) activesupport (>= 5.0, < 8.0) colorize (~> 1.1) launchy (~> 3.0) nokogiri (~> 1.16.5) active_delivery (0.4.4) active_flag (1.6.0) activerecord (>= 5) active_material (1.5.2) active_median (0.4.1) activesupport (>= 6.1) active_record_query_trace (1.8.1) active_type (2.4.1) activerecord (>= 3.2) activeadmin (3.2.2) arbre (~> 1.2, >= 1.2.1) csv formtastic (>= 3.1) formtastic_i18n (>= 0.4) inherited_resources (~> 1.7) jquery-rails (>= 4.2) kaminari (>= 1.2.1) railties (>= 6.1) ransack (>= 4.0) activeadmin_addons (1.9.0) active_material railties require_all sassc sassc-rails xdan-datetimepicker-rails (~> 2.5.1) activeadmin_json_editor (0.0.9) ace-rails-ap railties (>= 3.0) activejob (6.1.7.8) activesupport (= 6.1.7.8) globalid (>= 0.3.6) activejob-status (0.1.6) activejob (>= 4.2) activesupport (>= 4.2) activemodel (6.1.7.8) activesupport (= 6.1.7.8) activemodel-serializers-xml (1.0.2) activemodel (> 5.x) activesupport (> 5.x) builder (~> 3.1) activerecord (6.1.7.8) activemodel (= 6.1.7.8) activesupport (= 6.1.7.8) activerecord-cte (0.3.0) activerecord activerecord-import (1.5.0) activerecord (>= 4.2) activerecord-postgres_pub_sub (3.0.0) activerecord (> 6.0, < 7.2) pg (~> 1.1) private_attr with_advisory_lock activestorage (6.1.7.8) actionpack (= 6.1.7.8) activejob (= 6.1.7.8) activerecord (= 6.1.7.8) activesupport (= 6.1.7.8) marcel (~> 1.0) mini_mime (>= 1.1.0) activesupport (6.1.7.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) acts_as_tree (2.9.1) activerecord (>= 3.0.0) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) akami (1.3.1) gyoku (>= 0.4.0) nokogiri amazing_print (1.6.0) ancestry (4.3.3) activerecord (>= 5.2.6) annotate (3.1.1) activerecord (>= 3.2, < 7.0) rake (>= 10.4, < 14.0) api-auth (2.5.1) ar_lazy_preload (2.1.0) arbre (1.7.0) activesupport (>= 3.0.0) ruby2_keywords (>= 0.0.2) arel_extensions (2.0.21) activerecord (>= 6.0) argon2-kdf (0.2.0) ast (2.4.2) atlassian-jwt (0.2.1) jwt (~> 2.1) attr_encrypted (4.1.0) encryptor (~> 3.0.0) aws-eventstream (1.2.0) aws-partitions (1.790.0) aws-sdk-core (3.178.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) aws-sdk-kms (1.71.0) aws-sdk-core (~> 3, >= 3.177.0) aws-sigv4 (~> 1.1) aws-sdk-s3 (1.131.0) aws-sdk-core (~> 3, >= 3.177.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.6) aws-sdk-secretsmanager (1.81.0) aws-sdk-core (~> 3, >= 3.177.0) aws-sigv4 (~> 1.1) aws-sigv4 (1.6.0) aws-eventstream (~> 1, >= 1.0.2) bcrypt (3.1.20) bcrypt_pbkdf (1.1.0) benchmark-ips (2.9.1) benchmark-memory (0.2.0) memory_profiler (~> 1) better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) rouge (>= 1.0.0) better_html (2.1.1) actionview (>= 6.0) activesupport (>= 6.0) ast (~> 2.0) erubi (~> 1.4) parser (>= 2.4) smart_properties binding_of_caller (1.0.0) debug_inspector (>= 0.0.1) blind_index (2.5.0) activesupport (>= 6.1) argon2-kdf (>= 0.1.1) bootsnap (1.15.0) msgpack (~> 1.2) brakeman (5.4.1) builder (3.3.0) bullet (7.2.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) cancancan (3.2.1) capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) carrierwave (1.3.3) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) ssrf_filter (~> 1.0, < 1.1.0) cells (4.1.7) declarative-builder (< 0.2.0) declarative-option (< 0.2.0) tilt (>= 1.4, < 3) uber (< 0.2.0) cells-rails (0.1.5) actionpack (>= 5.0) cells (>= 4.1.6, < 5.0.0) character_set (1.8.0) childprocess (5.0.0) choice (0.2.0) chunky_png (1.4.0) cld (0.12.0) ffi client_side_validations (20.0.2) js_regex (~> 3.1) rails (>= 5.2, < 7.1) client_side_validations-simple_form (14.1.0) client_side_validations (>= 19.0, < 21) simple_form (~> 5.0) cocoon (1.2.14) code_ownership (1.36.1) code_teams (~> 1.0) packs-specification sorbet-runtime (>= 0.5.10821) code_teams (1.0.2) sorbet-runtime coderay (1.1.3) colorize (1.1.0) combine_pdf (1.0.26) matrix ruby-rc4 (>= 0.1.5) concurrent-ruby (1.3.4) connection_pool (2.4.1) constant_resolver (0.2.0) countries (4.0.1) i18n_data (~> 0.13.0) sixarm_ruby_unaccent (~> 1.1) country_select (6.0.0) countries (~> 4.0) sort_alphabetical (~> 1.1) crack (0.4.5) rexml crass (1.0.6) crc (0.4.2) csv (3.3.0) date (3.3.4) debug_inspector (1.1.0) declarative (0.0.20) declarative-builder (0.1.0) declarative-option (< 0.2.0) declarative-option (0.1.0) deep_cloneable (3.2.0) activerecord (>= 3.1.0, < 8) delayed_cron_job (0.9.0) fugit (>= 1.5) delayed_job (4.1.11) activesupport (>= 3.0, < 8.0) delayed_job_active_record (4.1.8) activerecord (>= 3.0, < 8.0) delayed_job (>= 3.0, < 5) dentaku (3.5.0) activesupport (>= 5.2) concurrent-ruby deprecation_toolkit (2.2.1) activesupport (>= 6.1) devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) devise-two-factor (4.1.0) activesupport (< 7.1) attr_encrypted (>= 1.3, < 5, != 2) devise (~> 4.0) railties (< 7.1) rotp (~> 6.0) devise_invitable (2.0.9) actionmailer (>= 5.0) devise (>= 4.6) devise_saml_authenticatable (1.9.1) devise (> 2.0.0) ruby-saml (~> 1.7) diff-lcs (1.5.1) diffy (3.4.2) discard (1.2.1) activerecord (>= 4.2, < 8) docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) doorkeeper (5.6.6) railties (>= 5) doorkeeper-openid_connect (1.8.7) doorkeeper (>= 5.5, < 5.7) jwt (>= 2.5) dotenv (3.1.2) dotenv-rails (3.1.2) dotenv (= 3.1.2) railties (>= 6.1) draper (4.0.2) actionpack (>= 5.0) activemodel (>= 5.0) activemodel-serializers-xml (>= 1.0) activesupport (>= 5.0) request_store (>= 1.0) ruby2_keywords ed25519 (1.2.4) encryptor (3.0.0) erb_lint (0.5.0) activesupport better_html (>= 2.0.1) parser (>= 2.7.1.4) rainbow rubocop smart_properties erbse (0.1.4) temple erubi (1.13.0) et-orbi (1.2.11) tzinfo event_stream_parser (1.0.0) excon (0.109.0) factory_bot (5.1.2) activesupport (>= 4.2.0) factory_bot_rails (5.1.1) factory_bot (~> 5.1.0) railties (>= 4.2.0) faraday (1.10.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) faraday-httpclient (~> 1.0) faraday-multipart (~> 1.0) faraday-net_http (~> 1.0) faraday-net_http_persistent (~> 1.0) faraday-patron (~> 1.0) faraday-rack (~> 1.0) faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) faraday-httpclient (1.0.1) faraday-multipart (1.0.4) multipart-post (~> 2) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) faraday_middleware (1.2.0) faraday (~> 1.0) fcm (1.0.8) faraday (>= 1.0.0, < 3.0) googleauth (~> 1) ffaker (2.21.0) ffi (1.15.5) file_validators (3.0.0) activemodel (>= 3.2) mime-types (>= 1.0) flipper (1.3.0) concurrent-ruby (< 2) flipper-active_record (1.3.0) activerecord (>= 4.2, < 8) flipper (~> 1.3.0) flipper-redis (1.3.0) flipper (~> 1.3.0) redis (>= 3.0, < 6) fog-aws (3.21.0) fog-core (~> 2.1) fog-json (~> 1.1) fog-xml (~> 0.1) fog-core (2.4.0) builder excon (~> 0.71) formatador (>= 0.2, < 2.0) mime-types fog-json (1.2.0) fog-core multi_json (~> 1.10) fog-xml (0.1.4) fog-core nokogiri (>= 1.5.11, < 2.0.0) formatador (1.1.0) formtastic (5.0.0) actionpack (>= 6.0.0) formtastic_i18n (0.7.0) fugit (1.11.1) et-orbi (~> 1, >= 1.2.11) raabro (~> 1.4) get_process_mem (0.2.7) ffi (~> 1.0) gitlab (4.19.0) httparty (~> 0.20) terminal-table (>= 1.5.1) gli (2.21.0) globalid (1.2.1) activesupport (>= 6.1) goldiloader (4.2.0) activerecord (>= 5.2, < 7.2) activesupport (>= 5.2, < 7.2) good_migrations (0.2.1) activerecord (>= 3.1) railties (>= 3.1) google-apis-calendar_v3 (0.14.0) google-apis-core (>= 0.4, < 2.a) google-apis-core (0.4.1) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) mini_mime (~> 1.0) representable (~> 3.0) retriable (>= 2.0, < 4.a) rexml webrick googleauth (1.1.0) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) gpgme (2.0.24) mini_portile2 (~> 2.7) guard (2.18.1) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) lumberjack (>= 1.0.12, < 2.0) nenv (~> 0.1) notiffany (~> 0.0) pry (>= 0.13.0) shellany (~> 0.0) thor (>= 0.18.1) guard-bundler (3.0.0) bundler (>= 2.1, < 3) guard (~> 2.2) guard-compat (~> 1.1) guard-compat (1.2.1) guard-minitest (2.4.6) guard-compat (~> 1.2) minitest (>= 3.0) guid (0.1.1) gyoku (1.3.1) builder (>= 2.1.2) has_scope (0.8.2) actionpack (>= 5.2) activesupport (>= 5.2) hashdiff (1.0.1) hashie (3.6.0) html_truncator (0.4.2) nokogiri (~> 1.5) htmltoword (1.1.1) actionpack nokogiri rubyzip (>= 1.0) http-accept (1.7.0) http-cookie (1.0.4) domain_name (~> 0.5) httparty (0.21.0) mini_mime (>= 1.0.0) multi_xml (>= 0.5.2) httpclient (2.8.3) httpi (2.4.5) rack socksify hunspell (1.1.0) i18n (1.14.5) concurrent-ruby (~> 1.0) i18n_data (0.13.0) inherited_resources (1.14.0) actionpack (>= 6.0) has_scope (>= 0.6) railties (>= 6.0) responders (>= 2) intercom-rails (1.0.1) activesupport (> 4.0) jbuilder (2.11.2) activesupport (>= 5.0.0) jira-ruby (2.3.0) activesupport atlassian-jwt multipart-post oauth (~> 0.5, >= 0.5.0) jmespath (1.6.2) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) js_regex (3.11.1) character_set (~> 1.4) regexp_parser (>= 2.6.2, < 3.0.0) regexp_property_values (~> 1.0) json (2.7.2) jwt (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) kaminari-activerecord (= 1.2.2) kaminari-core (= 1.2.2) kaminari-actionview (1.2.2) actionview kaminari-core (= 1.2.2) kaminari-activerecord (1.2.2) activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) language_server-protocol (3.17.0.3) launchy (3.0.1) addressable (~> 2.8) childprocess (~> 5.0) letter_opener (1.10.0) launchy (>= 2.2, < 4) linkedin-v2 (0.1.8) faraday (~> 1.0) hashie (~> 3.2) mime-types (>= 1.16) oauth2 (~> 1.0) liquid (5.0.1) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) logger (1.6.1) loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) lumberjack (1.2.10) mail (2.8.1) mini_mime (>= 0.1.1) net-imap net-pop net-smtp marcel (1.0.4) matrix (0.4.2) memoist (0.16.2) memory_profiler (1.0.2) method_source (1.1.0) mime-types (3.5.2) mime-types-data (~> 3.2015) mime-types-data (3.2023.1205) mini_magick (4.11.0) mini_mime (1.1.5) mini_portile2 (2.8.7) minitest (5.14.4) minitest-junit (2.1.0) minitest (~> 5.11) ox (~> 2, >= 2.14.2) minitest-stackprof (0.2.0) minitest (>= 5.0) stackprof (>= 0.2.7) minitest-stub_any_instance (1.0.3) mobility (1.3.0.rc3) i18n (>= 0.6.10, < 2) request_store (~> 1.0) mocha (2.0.2) ruby2_keywords (>= 0.0.5) msgpack (1.7.2) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.4.1) nenv (0.3.0) net-ftp (0.2.0) net-protocol time net-imap (0.3.6) date net-protocol net-pop (0.1.2) net-protocol net-protocol (0.2.2) timeout net-sftp (4.0.0) net-ssh (>= 5.0.0, < 8.0.0) net-smtp (0.5.0) net-protocol net-ssh (7.2.1) netrc (0.11.0) next_rails (1.3.0) colorize (>= 0.8.1) nilify_blanks (1.4.0) activerecord (>= 4.0.0) activesupport (>= 4.0.0) nio4r (2.7.3) nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) nori (2.6.0) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) numbers_and_words (0.11.12) i18n (<= 2) numo-narray (0.9.2.1) oauth (0.5.6) oauth2 (1.4.7) faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) octokit (4.25.1) faraday (>= 1, < 3) sawyer (~> 0.9) oj (3.16.1) omniauth (2.0.0) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) rack-protection omniauth-azure-activedirectory-v2 (1.0.0) omniauth-oauth2 (~> 1.7) omniauth-google-oauth2 (1.0.0) jwt (>= 2.0) oauth2 (~> 1.1) omniauth (~> 2.0) omniauth-oauth2 (~> 1.7.1) omniauth-oauth2 (1.7.2) oauth2 (~> 1.4) omniauth (>= 1.9, < 3) openssl (3.2.0) optparse (0.5.0) order_as_specified (1.7) activerecord (>= 5.0.0) orm_adapter (0.5.0) os (1.1.4) ownership (0.2.0) ox (2.14.18) packs (0.0.37) code_ownership (>= 1.33.0) packs-specification packwerk parse_packwerk rainbow sorbet-runtime thor tty-prompt packs-rails (0.0.5) activesupport packs railties packs-specification (0.0.10) sorbet-runtime packwerk (3.1.0) activesupport (>= 6.0) ast better_html bundler constant_resolver (>= 0.2.0) parallel parser sorbet-runtime (>= 0.5.9914) zeitwerk (>= 2.6.1) packwerk-extensions (0.1.4) packwerk (>= 2.2.1) railties (>= 6.0.0) sorbet-runtime zeitwerk pagy (6.0.4) paper_trail (12.3.0) activerecord (>= 5.2) request_store (~> 1.1) parallel (1.25.1) parallel_tests (4.7.1) parallel parse_packwerk (0.21.0) sorbet-runtime parser (3.3.4.2) ast (~> 2.4.1) racc pastel (0.8.0) tty-color (~> 0.5) pg (1.5.4) prism (1.0.0) private_attr (2.0.0) prometheus_exporter (2.0.3) webrick pronto (0.11.1) gitlab (>= 4.4.0, < 5.0) httparty (>= 0.13.7, < 1.0) octokit (>= 4.7.0, < 7.0) rainbow (>= 2.2, < 4.0) rexml (>= 3.2.5, < 4.0) rugged (>= 0.23.0, < 2.0) thor (>= 0.20.3, < 2.0) pronto-erb_lint (0.1.6) erb_lint (~> 0.1, >= 0.1.1) pronto (~> 0.9, > 0.9.0) pronto-eslint_npm (0.11.0) pronto (~> 0.11.0) pronto-rubocop (0.11.5) pronto (~> 0.11.0) rubocop (>= 0.63.1, < 2.0) pronto-stylelint (0.10.2) pronto (>= 0.10, < 0.12) rugged (>= 0.24, < 2.0) pronto-yamllint (0.2.0) pronto (~> 0.11.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) pry-byebug (3.10.1) byebug (~> 11.0) pry (>= 0.13, < 0.15) pry-doc (1.5.0) pry (~> 0.11) yard (~> 0.9.11) pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.7) puma (6.4.2) nio4r (~> 2.0) puma_worker_killer (0.3.1) get_process_mem (~> 0.2) puma (>= 2.7) pusher (2.0.3) httpclient (~> 2.8) multi_json (~> 1.15) pusher-signature (~> 0.1.8) pusher-signature (0.1.8) raabro (1.4.0) racc (1.8.1) rack (2.2.9) rack-attack (6.7.0) rack (>= 1.0, < 4) rack-cors (1.1.1) rack (>= 2.0.0) rack-mini-profiler (3.3.0) rack (>= 1.2.0) rack-protection (2.2.0) rack rack-proxy (0.7.0) rack rack-test (2.1.0) rack (>= 1.3) rack-timeout (0.6.0) rails (6.1.7.8) actioncable (= 6.1.7.8) actionmailbox (= 6.1.7.8) actionmailer (= 6.1.7.8) actionpack (= 6.1.7.8) actiontext (= 6.1.7.8) actionview (= 6.1.7.8) activejob (= 6.1.7.8) activemodel (= 6.1.7.8) activerecord (= 6.1.7.8) activestorage (= 6.1.7.8) activesupport (= 6.1.7.8) bundler (>= 1.15.0) railties (= 6.1.7.8) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) activesupport (>= 5.0.1.rc1) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) rails-erd (1.7.2) activerecord (>= 4.2) activesupport (>= 4.2) choice (~> 0.2.0) ruby-graphviz (~> 1.2) rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) railties (6.1.7.8) actionpack (= 6.1.7.8) activesupport (= 6.1.7.8) method_source rake (>= 12.2) thor (~> 1.0) rainbow (3.1.1) rake (13.2.1) ransack (4.1.1) activerecord (>= 6.1.5) activesupport (>= 6.1.5) i18n rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) rbi (0.2.0) prism (~> 1.0) sorbet-runtime (>= 0.5.9204) rbs (3.5.3) logger recaptcha (5.8.1) json record_tag_helper (1.0.1) actionview (>= 5) redcarpet (3.5.1) redis (4.8.1) regexp_parser (2.9.2) regexp_property_values (1.5.2) representable (3.1.1) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) request_store (1.5.0) rack (>= 1.4) request_store_rails (2.0.0) concurrent-ruby (~> 1.0) require_all (3.0.0) responders (3.1.1) actionpack (>= 5.2) railties (>= 5.2) rest-client (2.1.0) http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) retriable (3.1.2) rexml (3.3.7) ros-apartment (3.0.4) activerecord (>= 6.1.0, < 7.2) parallel (< 2.0) public_suffix (>= 2.0.5, < 6.0) rack (>= 1.3.6, < 4.0) rotp (6.2.0) rouge (4.3.0) rqrcode (0.10.1) chunky_png (~> 1.0) rubocop (1.65.1) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 2.4, < 3.0) rexml (>= 3.2.5, < 4.0) rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) rubocop-ast (1.32.0) parser (>= 3.3.1.0) rubocop-minitest (0.35.1) rubocop (>= 1.61, < 2.0) rubocop-ast (>= 1.31.1, < 2.0) rubocop-performance (1.11.5) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) rubocop-rails (2.12.4) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) rubocop-sorbet (0.8.5) rubocop (>= 1) ruby-graphviz (1.2.5) rexml ruby-lsp (0.17.17) language_server-protocol (~> 3.17.0) prism (~> 1.0) rbs (>= 3, < 4) sorbet-runtime (>= 0.5.10782) ruby-lsp-shoulda-context (0.4.6) dotenv (>= 2.7.6, < 4.0) ruby-lsp (~> 0.17.17, >= 0.17.17) ruby-ole (1.2.12.2) ruby-openai (7.1.0) event_stream_parser (>= 0.3.0, < 2.0.0) faraday (>= 1) faraday-multipart (>= 1) ruby-progressbar (1.13.0) ruby-rc4 (0.1.5) ruby-saml (1.12.3) nokogiri (>= 1.10.5) rexml ruby2_keywords (0.0.5) rubyXL (3.4.27) nokogiri (>= 1.10.8) rubyzip (>= 1.3.0) ruby_http_client (3.5.5) rubyzip (2.0.0) rugged (1.6.3) sanitize (6.1.2) crass (~> 1.0.2) nokogiri (>= 1.12.0) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) sassc (2.4.0) ffi (~> 1.9) sassc-rails (2.1.2) railties (>= 4.0.0) sassc (>= 2.0) sprockets (> 3.0) sprockets-rails tilt savon (2.12.1) akami (~> 1.2) builder (>= 2.1.2) gyoku (~> 1.2) httpi (~> 2.3) nokogiri (>= 1.8.1) nori (~> 2.4) wasabi (~> 3.4) sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) scenic (1.8.0) activerecord (>= 4.0.0) railties (>= 4.0.0) scss_lint (0.60.0) sass (~> 3.5, >= 3.5.5) selenium-webdriver (4.16.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) semantic_range (3.0.0) sendgrid-ruby (6.7.0) ruby_http_client (~> 3.4) sentry-delayed_job (5.16.1) delayed_job (>= 4.0) sentry-ruby (~> 5.16.1) sentry-rails (5.16.1) railties (>= 5.0) sentry-ruby (~> 5.16.1) sentry-ruby (5.16.1) concurrent-ruby (~> 1.0, >= 1.0.2) shellany (0.0.1) shoulda-context (2.0.0) shoulda-matchers (6.3.0) activesupport (>= 5.2.0) signet (0.16.0) addressable (~> 2.8) faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) simple_form (5.3.1) actionpack (>= 5.2) activemodel (>= 5.2) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) simplecov_json_formatter (~> 0.1) simplecov-html (0.12.3) simplecov_json_formatter (0.1.3) sixarm_ruby_unaccent (1.2.0) slack-ruby-client (1.0.0) faraday (>= 1.0) faraday_middleware gli hashie websocket-driver slowpoke (0.3.2) actionpack rack-timeout (>= 0.4.0) railties (>= 5) smart_properties (1.17.0) socksify (1.7.1) sorbet (0.5.11471) sorbet-static (= 0.5.11471) sorbet-runtime (0.5.11471) sorbet-static (0.5.11471-universal-darwin) sorbet-static (0.5.11471-x86_64-linux) sorbet-static-and-runtime (0.5.11471) sorbet (= 0.5.11471) sorbet-runtime (= 0.5.11471) sort_alphabetical (1.1.0) unicode_utils (>= 1.2.2) spoom (1.4.2) erubi (>= 1.10.0) prism (>= 0.28.0) sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) spreadsheet (1.3.0) ruby-ole sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) sprockets-rails (3.5.2) actionpack (>= 6.1) activesupport (>= 6.1) sprockets (>= 3.0.0) ssrf_filter (1.0.8) stackprof (0.2.26) swagger-blocks (3.0.0) tapioca (0.16.2) bundler (>= 2.2.25) netrc (>= 0.11.0) parallel (>= 1.21.0) rbi (~> 0.2) sorbet-static-and-runtime (>= 0.5.11087) spoom (>= 1.2.0) thor (>= 1.2.0) yard-sorbet telephone_number (1.4.16) temping (4.2.0) activerecord (>= 6.0, < 7.3) activesupport (>= 6.0, < 7.3) temple (0.10.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) test-prof (1.2.2) thor (1.2.1) tilt (2.0.11) time (0.2.2) date timeliness (0.4.4) timeout (0.4.1) trailblazer-option (0.1.2) translate_enum (0.1.3) activesupport tty-color (0.6.0) tty-cursor (0.7.1) tty-prompt (0.23.1) pastel (~> 0.8) tty-reader (~> 0.8) tty-reader (0.9.0) tty-cursor (~> 0.7) tty-screen (~> 0.8) wisper (~> 2.0) tty-screen (0.8.1) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) unf (0.1.4) unf_ext unf_ext (0.0.7.7) unicode-display_width (2.5.0) unicode_utils (1.4.0) uniform_notifier (1.16.0) validate_url (1.0.15) activemodel (>= 3.0.0) public_suffix validates_timeliness (4.1.1) timeliness (>= 0.3.10, < 1) warden (1.2.9) rack (>= 2.0.9) wasabi (3.5.0) httpi (~> 2.0) nokogiri (>= 1.4.2) webmock (3.18.1) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) webpacker (5.4.0) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) webrick (1.8.1) websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) wicked_pdf (2.6.3) activesupport wisper (2.0.1) with_advisory_lock (4.6.0) activerecord (>= 4.2) write_xlsx (1.09.5) rubyzip (>= 1.0.0) xdan-datetimepicker-rails (2.5.4) jquery-rails rails (>= 3.2.16) xlsxtream (2.4.0) zip_tricks (>= 4.5, < 6) xml-simple (1.1.9) rexml xpath (3.2.0) nokogiri (~> 1.8) yard (0.9.36) yard-activerecord (0.0.16) yard (>= 0.8.3) yard-sorbet (0.9.0) sorbet-runtime yard zeitwerk (2.6.18) zip_tricks (5.5.0) PLATFORMS arm64-darwin x86_64-darwin-21 x86_64-darwin-22 x86_64-darwin-23 x86_64-linux DEPENDENCIES abstract_notifier active-record-query-count (~> 0.1.4) active_delivery active_flag (~> 1.6) active_median (~> 0.4) active_record_query_trace (~> 1.8) active_type (~> 2.4.1) activeadmin (= 3.2.2) activeadmin_addons activeadmin_json_editor (~> 0.0.7) activejob-status activerecord-cte activerecord-import (~> 1.5) activerecord-postgres_pub_sub (~> 3.0.0) acts_as_tree addressable (~> 2.7) amazing_print (~> 1.6) ancestry (~> 4.3) annotate (~> 3.1) api-auth ar_lazy_preload arel_extensions (~> 2.0.21) attr_encrypted (~> 4.1.0) automation! aws-sdk-s3 (~> 1) aws-sdk-secretsmanager (~> 1.81) bcrypt (~> 3.1.20) bcrypt_pbkdf (~> 1.0) benchmark-ips (~> 2.9) benchmark-memory (~> 0.2) better_errors (~> 2.10) binding_of_caller (~> 1.0) blind_index boost_api! bootsnap (= 1.15.0) brakeman (~> 5.4) buk_extract_i18n (~> 1.0)! bullet (~> 7.0) byebug (~> 11.1) cancancan (~> 3.2.1) capybara carrierwave (~> 1.3) cells-rails cld (~> 0.12.0) client_side_validations (~> 20.0.2) client_side_validations-simple_form (~> 14.1.0) cocoon combine_pdf connection_pool country_select country_sti! crc data_uri! deep_cloneable delayed_cron_job (~> 0.9.0) delayed_job_active_record dentaku (~> 3.5) deprecation_toolkit (~> 2.2) devise devise-two-factor (~> 4.1) devise_invitable devise_saml_authenticatable discard (~> 1.2.1) doorkeeper (~> 5.6) doorkeeper-openid_connect (~> 1.8) dotenv-rails (~> 3.1) eav_hashes! ed25519 (~> 1.2) ensure_gem_version! erb_lint (~> 0.5) erbse (>= 0.1.4) factory_bot factory_bot_rails fcm (~> 1.0) ffaker (~> 2.21.0) fiji! file_validators fixy! flipper (~> 1.3.0) flipper-active_record flipper-redis fog-aws (>= 0.6.0) goldiloader (~> 4.2) good_migrations (~> 0.2) google-apis-calendar_v3 (~> 0.14.0) gpgme guard (~> 2.18) guard-bundler (~> 3.0) guard-minitest (~> 2.4) html_truncator (~> 0.2) htmltoword hunspell i18n-recursive-lookup! intercom-rails (~> 1.0.1) jbuilder (~> 2.11) jira-ruby (~> 2.3) jwt kaminari (~> 1.2.2) letter_opener (~> 1.8) linkedin-v2 (~> 0.1.0) liquid memory_profiler mini_magick (>= 4.5.1) minitest (~> 5.14) minitest-junit (~> 2.1) minitest-stackprof (~> 0.2) minitest-stub_any_instance mobility (~> 1.3.0.rc3) mocha (~> 2.0) net-ftp net-imap net-pop net-sftp net-smtp next_rails (~> 1.3.0) nilify_blanks numbers_and_words (~> 0.11.12) numo-narray (~> 0.9.2.1) oauth (~> 0.5.6) octokit (~> 4.25) oj omniauth omniauth-azure-activedirectory-v2 omniauth-google-oauth2 omniauth-office365! openssl (~> 3.2.0) optparse order_as_specified ownership packs-rails packwerk packwerk-extensions pagy (~> 6.0.4) paper_trail (~> 12.3) parallel parallel_tests (~> 4.7) pg plaintext! prometheus_integration! pronto (~> 0.11) pronto-erb_lint (~> 0.1.6) pronto-eslint_npm (~> 0.11) pronto-rubocop (~> 0.11.5) pronto-stylelint (~> 0.10) pronto-yamllint (~> 0.2) pry (~> 0.14) pry-byebug (~> 3.10) pry-doc (~> 1.5) pry-rails (~> 0.3) puma puma_worker_killer pusher rack-attack (~> 6.7) rack-cors rack-mini-profiler rails (~> 6.1.7) rails-controller-testing (~> 1.0) rails-erd (~> 1.7.2) rails_workflow! railties ransack recaptcha record_tag_helper redcarpet (~> 3.5) redis request_store_rails rest-client (~> 2.1) ros-apartment (~> 3.0.0) rqrcode rubocop (~> 1.60) rubocop-buk (~> 0.1)! rubocop-minitest (~> 0.35) rubocop-performance (~> 1.11) rubocop-rails (~> 2.12) rubocop-sorbet ruby-lsp-i18n! ruby-lsp-shoulda-context (~> 0.4.6) ruby-openai (~> 7.1) ruby-progressbar (~> 1.8, >= 1.8.1) rubyXL sanitize savon (~> 2.12.1) scenic (~> 1.8.0) scss_lint selenium-webdriver (~> 4.4) sendgrid-ruby sentry-delayed_job sentry-rails sentry-ruby (~> 5.16) shoulda-context (~> 2.0) shoulda-matchers (~> 6.3) simple_form (~> 5.3.1) simplecov (~> 0.21) slack-ruby-client slowpoke sorbet sorbet-runtime spoom spreadsheet stackprof (>= 0.2.26) swagger-blocks tapioca telephone_number temping temple (~> 0.10) terminal-table (~> 3.0) test-prof (~> 1.2) thor timeliness (>= 0.4.2) traceroute! translate_enum turbolinks twemoji! validate_url validates_timeliness (~> 4.0) webmock (~> 3.18) webpacker (~> 5.4) wicked_pdf (~> 2.6.3) with_advisory_lock write_xlsx xlsxtream xml-simple (~> 1.1.9) yard (~> 0.9) yard-activerecord (~> 0.0) yard-buk (~> 0.1)! BUNDLED WITH 2.4.22 ```

Expected Behavior

The test should pass. I noticed that the value is actually saved, its like the column updates but the validation of PG fails.

Actual Behavior

The test fails, specifically, the update! execution of:

General.find_or_initialize_by(nombre: nombre).update!(valor: valor.to_s)

Possible Fix

Hugo-Lm commented 8 hours ago

Hey @crow-rojas,

The issue arises because there is a non-null constraint on the "valor" column in your "General" table, while simultaneously using translates :valor, type: :string in your model. When employing Mobility with the backend :key_value configuration, the field for which you use translates are stored in one of Mobility's translation tables (string or text).

As a result, when you create/update an entry, the "valor" field is saved in Mobility's dedicated translation table, not in the "valor" column of your General table, leading to the error.

To resolve this, you should remove the "valor" column from your General table, or at least eliminate the non-null constraint.

Hope it was clear and will help