# Manipulating custom user fields from the Rails console

**URL:** <https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613>\
**Category:** Development\
**Tags:** rails-console, user-custom-fields\
**Created:** [February 17, 2022, 9:12pm 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:** 3

<div class="post-metadata">

**Author:** ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)\
**Post date:** [February 18, 2022, 10:46am UTC](https://meta.discourse.org/t/manipulating-custom-user-fields-from-the-rails-console/218613/3 "2022-02-18T10:46:47Z")

</div>

Also something like

```
UserCustomField.create(user_id: 1, name: "user_field_4",value: "Oops")

```

Oh, but if that already has a value, it’ll add a second one! So you might

```
 ucf=UserCustomField.find_by(user_id: name: 'user_field_4')

```

and then you’d need to either update it or create a new one.

But if you do create multiple ones, the UX will show them comma-separated, and if they are edited via the UX when they get saved, they get saved back to a single value.

You can have a look at them with

```
  UserCustomField.all

```

Or

```
UserCustomField.where(name: x)

```

~~That’s by memory on my phone so your mileage may vary.~~

---

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