{"record":{"id":"f431cbe7cdcc0422","repo":"railsadminteam/rails_admin","slug":"the-momentjs-format-configuration-option-is-deprec","errorCode":null,"errorMessage":"The momentjs_format configuration option is deprecated, please use flatpickr_format with corresponding values here: https://flatpickr.js.org/formatting/","messagePattern":"The momentjs_format configuration option is deprecated, please use flatpickr_format with corresponding values here: https://flatpickr\\.js\\.org/formatting/","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/rails_admin/config/fields/types/datetime.rb","lineNumber":86,"sourceCode":"          register_instance_option :queryable? do\n            false\n          end\n\n          register_instance_option :formatted_value do\n            time = (value || default_value)\n            if time\n              ::I18n.l(time, format: strftime_format)\n            else\n              ''.html_safe\n            end\n          end\n\n          register_instance_option :partial do\n            :form_datetime\n          end\n\n          register_deprecated_instance_option :momentjs_format do\n            ActiveSupport::Deprecation.warn('The momentjs_format configuration option is deprecated, please use flatpickr_format with corresponding values here: https://flatpickr.js.org/formatting/')\n          end\n\n          def form_value\n            value&.in_time_zone&.strftime('%FT%T') || form_default_value\n          end\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":68,"sourceCodeEnd":97,"githubUrl":"https://github.com/railsadminteam/rails_admin/blob/0690a5e62f8d99bc00495a3754f5189b23124387/lib/rails_admin/config/fields/types/datetime.rb#L68-L97","documentation":"RailsAdmin swapped its date/time picker from moment.js to flatpickr. The datetime field type kept momentjs_format (lib/rails_admin/config/fields/types/datetime.rb:85) only as a deprecated stub whose block prints this ActiveSupport::Deprecation warning; the format string you pass is discarded. Date formatting/parsing now goes through the flatpickr_format instance option, using flatpickr's token syntax.","triggerScenarios":"A field config like `field :published_at, :datetime do momentjs_format 'YYYY-MM-DD HH:mm' end`. The warning fires when that model config is evaluated (first admin request touching the model), and — worse — the picker silently falls back to the default flatpickr format, so the form renders the wrong format with no error.","commonSituations":"Upgrading an app from rails_admin that used moment.js (< the flatpickr switch) and keeping the old initializer verbatim; moment format tokens ('YYYY', 'HH:mm') silently meaning nothing to flatpickr ('Y', 'H:i'); CI with deprecations promoted to errors failing on admin specs.","solutions":["Replace momentjs_format with flatpickr_format and translate the tokens — moment 'YYYY-MM-DD HH:mm' becomes flatpickr 'Y-m-d H:i' (reference: https://flatpickr.js.org/formatting/).","After switching, exercise the create/edit form of that model once and confirm the picker parses and redisplays values in the expected format, since wrong tokens fail silently rather than raising.","Grep for momentjs_format across initializers (and any per-model config blocks) — each occurrence warns separately."],"exampleFix":"# before\nRailsAdmin.config do |config|\n  config.model Post do\n    field :published_at, :datetime do\n      momentjs_format 'YYYY-MM-DD HH:mm'\n    end\n  end\nend\n\n# after (flatpickr tokens: https://flatpickr.js.org/formatting/)\nRailsAdmin.config do |config|\n  config.model Post do\n    field :published_at, :datetime do\n      flatpickr_format 'Y-m-d H:i'\n    end\n  end\nend","handlingStrategy":"validation","validationCode":"# Translate and validate up front instead of porting blindly\nMOMENT_TO_FLATPICKR = { 'YYYY' => 'Y', 'YY' => 'y', 'MM' => 'm', 'DD' => 'd', 'HH' => 'H', 'hh' => 'h', 'mm' => 'i', 'ss' => 'S', 'A' => 'K' }.freeze\nmoment = 'YYYY-MM-DD HH:mm'\nflatpickr = moment.gsub(Regexp.union(MOMENT_TO_FLATPICKR.keys), MOMENT_TO_FLATPICKR) # => 'Y-m-d H:i'\nraise 'untranslated tokens remain' unless flatpickr.scan(/[A-Za-z]/ - %w[Y m d H i]).empty?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After switching to flatpickr_format, render one edit form and assert the input's value matches the expected format — wrong tokens fail silently.","Keep date formats in one place per project (a helper/constant) instead of repeating format strings per field.","On picker-library swaps generally, add a round-trip spec: set value via the picker, save, reload, assert displayed format."],"tags":["rails-admin","deprecation","datetime","flatpickr","momentjs","configuration","ruby"],"backgroundTag":"deprecated-config-option","analyzedSha":"0690a5e62f8d99bc00495a3754f5189b23124387","analyzedAt":"2026-08-21T18:31:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}