# Нестабильное поведение в классе UserUpdater

**URL:** <https://meta.discourse.org/t/inconsistent-behaviour-in-userupdater-class/161360>\
**Category:** Development\
**Created:** [19.Август.2020 09:58:37 UTC](https://meta.discourse.org/t/inconsistent-behaviour-in-userupdater-class/161360 "2020-08-19T09:58:37Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)\
**Post date:** [20.Август.2020 06:28:34 UTC](https://meta.discourse.org/t/inconsistent-behaviour-in-userupdater-class/161360/5 "2020-08-20T06:28:34Z")

</div>

Мой анализ сводится к следующему.

```plaintext
# случай 1
u1 = User.find(1)
u1.custom_fields[:user_field_1] = "abc"
u1.save

# случай 2
u1.custom_fields["user_field_1"] = "abc"
u1.save

```

В случае 1 при каждом вызове `u1.save` создается новая запись `UserCustomField`.

 ![Screenshot 2020-08-20 at 11.52.09 AM](https://global.discourse-cdn.com/meta/original/3X/3/a/3a26e5d24f52fd2d97cc7350253040ad51455bde.png)

В случае 2 из базы данных удаляются все записи `UserCustomField` с именем ‘user\_field\_1’, кроме указанной.  
 ![Screenshot 2020-08-20 at 11.56.49 AM](https://cdck-file-uploads-global.s3.dualstack.us-west-2.amazonaws.com/meta/original/3X/e/3/e3082d7f74f04f21a31a9d78205dc3497ee9b89f.png)

В целом, версии ключа в виде `символа` и `строки` в миксине `HasCustomFields` обрабатываются по-разному.

---

_[View the full topic](https://meta.discourse.org/t/inconsistent-behaviour-in-userupdater-class/161360)._
