{"action":"opened","issue":{"url":"https://api.github.com/repos/mongoid/mongoid/issues/4055","labels_url":"https://api.github.com/repos/mongoid/mongoid/issues/4055/labels{/name}","comments_url":"https://api.github.com/repos/mongoid/mongoid/issues/4055/comments","events_url":"https://api.github.com/repos/mongoid/mongoid/issues/4055/events","html_url":"https://github.com/mongoid/mongoid/issues/4055","id":71850936,"number":4055,"title":"Mongoid localized field not being set in first form submission","user":{"login":"james-ai","id":910403,"avatar_url":"https://avatars.githubusercontent.com/u/910403?v=3","gravatar_id":"","url":"https://api.github.com/users/james-ai","html_url":"https://github.com/james-ai","followers_url":"https://api.github.com/users/james-ai/followers","following_url":"https://api.github.com/users/james-ai/following{/other_user}","gists_url":"https://api.github.com/users/james-ai/gists{/gist_id}","starred_url":"https://api.github.com/users/james-ai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/james-ai/subscriptions","organizations_url":"https://api.github.com/users/james-ai/orgs","repos_url":"https://api.github.com/users/james-ai/repos","events_url":"https://api.github.com/users/james-ai/events{/privacy}","received_events_url":"https://api.github.com/users/james-ai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-29T11:32:31Z","updated_at":"2015-04-29T11:32:31Z","closed_at":null,"body":"I've asked this question on Stack Overflow but not had much luck: http://stackoverflow.com/questions/29899935/mongoid-localized-field-not-being-set-in-first-form-submission\r\n\r\nEnvironment:\r\nRails 4.2.0\r\nRuby 2.1.2\r\nMongoid 4.0.0\r\n\r\nI have a simple_form with fields `name`, and `display_name`. Both are localised => true but `name` is disabled on the form.\r\n\r\nWhen I submit the form with a value in `display_name` Mongoid doesn't see the value for `display_name`, i.e. `\"dn\"=>{}`\r\n\r\n```\r\nStarted PATCH \"/admin/competitions/53d11b01736e7358b57a0000\" for ::1 at 2015-04-27 16:20:11 +0100\r\n    Processing by Admin::CompetitionsController#update as HTML\r\n      Parameters: {\"utf8\"=>\"✓\", \"authenticity_token\"=>\"[hidden]\", \"competition\"=>{\"display_name\"=>\"Capital One Cup\", \"country_id\"=>\"53d11af2736e7358b5190000\"}, \"commit\"=>\"Update Competition\", \"id\"=>\"53d11b01736e7358b57a0000\"}\r\n    D, [2015-04-27T16:20:11.537579 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 QUERY        database=dev collection=users selector={\"$query\"=>{\"_id\"=>BSON::ObjectId('53f74b79736e73452f000000')}, \"$orderby\"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil runtime: 1.7300ms\r\n    D, [2015-04-27T16:20:11.539357 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 QUERY        database=dev collection=competitions selector={\"_id\"=>BSON::ObjectId('53d11b01736e7358b57a0000')} flags=[] limit=0 skip=0 batch_size=nil fields=nil runtime: 0.5760ms\r\n    D, [2015-04-27T16:20:11.561547 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 UPDATE       database=dev collection=competitions selector={\"_id\"=>BSON::ObjectId('53d11b01736e7358b57a0000')} update={\"$set\"=>{\"dn\"=>{}, \"updated_at\"=>2015-04-27 15:20:11 UTC}} flags=[]\r\n    D, [2015-04-27T16:20:11.561685 #5896] DEBUG -- :                          COMMAND      database=dev command={:getlasterror=>1, :w=>1} runtime: 18.4320ms\r\n    Redirected to http://localhost:3000/admin/competitions\r\n    Completed 302 Found in 39ms\r\n```\r\n\r\nNow if I edit the object and give it a display name again Mongoid picks up the change and writes it to the DB. i.e. `\"dn\"=>{\"en\"=>\"Capital One Cup\"}`\r\n\r\n```\r\nStarted PATCH \"/admin/competitions/53d11b01736e7358b57a0000\" for ::1 at 2015-04-27 16:25:34 +0100\r\n    Processing by Admin::CompetitionsController#update as HTML\r\n      Parameters: {\"utf8\"=>\"✓\", \"authenticity_token\"=>\"[hidden]\", \"competition\"=>{\"display_name\"=>\"Capital One Cup\", \"country_id\"=>\"53d11af2736e7358b5190000\"}, \"commit\"=>\"Update Competition\", \"id\"=>\"53d11b01736e7358b57a0000\"}\r\n    D, [2015-04-27T16:25:34.465519 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 QUERY        database=dev collection=users selector={\"$query\"=>{\"_id\"=>BSON::ObjectId('53f74b79736e73452f000000')}, \"$orderby\"=>{:_id=>1}} flags=[] limit=-1 skip=0 batch_size=nil fields=nil runtime: 0.8160ms\r\n    D, [2015-04-27T16:25:34.469391 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 QUERY        database=dev collection=competitions selector={\"_id\"=>BSON::ObjectId('53d11b01736e7358b57a0000')} flags=[] limit=0 skip=0 batch_size=nil fields=nil runtime: 0.5070ms\r\n    D, [2015-04-27T16:25:34.497381 #5896] DEBUG -- :   MOPED: 127.0.0.1:27017 UPDATE       database=dev collection=competitions selector={\"_id\"=>BSON::ObjectId('53d11b01736e7358b57a0000')} update={\"$set\"=>{\"dn\"=>{\"en\"=>\"Capital One Cup\"}, \"updated_at\"=>2015-04-27 15:25:34 UTC}} flags=[]\r\n    D, [2015-04-27T16:25:34.497525 #5896] DEBUG -- :                          COMMAND      database=dev command={:getlasterror=>1, :w=>1} runtime: 23.9000ms\r\n    Redirected to http://localhost:3000/admin/competitions\r\n    Completed 302 Found in 39ms\r\n```\r\n\r\nIn config/application.rb I have set:\r\n\r\n    config.i18n.fallbacks = true\r\n    config.i18n.default_locale = :en"}}