# Using HasCustomFields in a plugin

**URL:** https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469
**Category:** Development
**Created:** [January 18, 2021, 5:50pm UTC](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469 "2021-01-18T17:50:53Z")
**Posts on this page:** 1
**Showing post:** 7

<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: [January 18, 2021, 9:13pm UTC](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469/7 "2021-01-18T21:13:29Z")

</div>

Ha! You did it! Thanks so much. I switched it to `server_id` and then did this in my `server.rb` model:

```ruby
    def custom_fields_fk
      @custom_fields_fk ||= "server_id"
    end

```

As long as that’s going to override that only for this model and not break `user_custom_field` and friends I think I should be ready to start beating myself over the head again on [Best way to enforce permissions--controller or constraint?](https://meta.discourse.org/t/best-way-to-enforce-permissions-controller-or-constraint/176113). And then I can add routes to do stuff like fill my new custom fields with . . . something.

I can’t thank you enough. You likely saved me a whole day. I owe you a 🍺!

---

_[View the full topic](https://meta.discourse.org/t/using-hascustomfields-in-a-plugin/176469)._
