# معالجة حقول المستخدم المخصصة من كونسول Rails

**URL:** <https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613>\
**Category:** Development\
**Tags:** rails-console, user-custom-fields\
**Created:** [17 فبراير 2022، 9:12م UTC](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613 "2022-02-17T21:12:08Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![nathank](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nathank/32/290039_2.png) [@nathank](https://meta.discourse.org/u/nathank)\
**Post date:** [7 مايو 2022، 1:09م UTC](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613/7 "2022-05-07T13:09:17Z")

</div>

أجد هذه أداة مفيدة للحصول على بناء جملة rails الصحيح عند الرغبة في معالجة UCFs هذه في وحدة تحكم rails:

##### إذا كنت تستبدل بيانات في هذا الحقل

```plaintext
UserCustomField.find_by(user_id: =UserID=, name: "=UserFieldName=").update(value: "=NewValue=")

```

(سيؤدي ذلك إلى ظهور خطأ إذا لم تكن هناك بيانات في هذا الحقل بعد)

##### إذا كنت تملأ هذا الحقل لأول مرة

```plaintext
UserCustomField.create(user_id: =UserID=, name: "=UserFieldName=",value: "=NewValue=")

```

---

_[View the full topic](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613)._
