# Custom Field not working

**URL:** <https://meta.discourse.org/t/custom-field-not-working/89983>\
**Category:** Development\
**Created:** [June 15, 2018, 4:52pm UTC](https://meta.discourse.org/t/custom-field-not-working/89983 "2018-06-15T16:52:29Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Sanjay1](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@Sanjay1](https://meta.discourse.org/u/Sanjay1)\
**Post date:** [June 15, 2018, 4:52pm UTC](https://meta.discourse.org/t/custom-field-not-working/89983/1 "2018-06-15T16:52:29Z")

</div>

Hi All,

I am fairly new to discourse and I am attempting to add a customs field but I am not able to,

Could someone please help me.

My code

```plaintext
after_initialize do

  module ::Foo
  	 PLUGIN_NAME ||= -"discourse-myapi"
     STORE_NAME ||= "replies".freeze

    class Engine < ::Rails::Engine
      engine_name PLUGIN_NAME
      isolate_namespace Foo

    end
  end

  require_dependency "application_controller"

  class Foo::Example
  	class << self

        def bump(id)
           cf_time = Time.zone.now 	
          DistributedMutex.synchronize("#{Foo::PLUGIN_NAME}-#{cf_time.iso8601}") do
          	user = User.find(id)
            user.custom_fields['signature_url'] = cf_time
            user.save!
            return user
          end
        end

  	end	
  end

  class Foo::BarController < ::ApplicationController

  	requires_plugin Foo::PLUGIN_NAME

    def custom_field_test
      begin
        user = Foo::Example.bump(1)
        render json: { user: user }
      rescue StandardError => e
        render_json_error e.message
      end
    end

  end

  Foo::Engine.routes.draw do'
    get '/custom_field_test' => 'bar#custom_field_test'
  end

  Discourse::Application.routes.append do
    mount ::Foo::Engine, at: '/myapiclass'
  end

end

```

Thanks

---

_[View the full topic](https://meta.discourse.org/t/custom-field-not-working/89983)._
