"wrong number of arguments" on Upgrade to new version

I upgraded to 3.1.0.beta4 and now one of my plugins is not working anymore and i have a hard time figuring out how to upgrade this part of the code:

after_initialize do

  User.register_custom_field_type('myfield', :json)

  # We need to make it editable to allow API access
  register_editable_user_custom_field :myfield
  register_editable_user_custom_field myfield: {}  **<---- ERROR IS HERE**

  # This will add the field inside the post json
  add_to_serializer(:post, :user_myfield, false) {
    # Staff is Admin + Moderator
    object.user.custom_fields['myfield'] if object.user && scope.is_staff?
  }

end

This is the error during upgrade:

I, [2023-04-18T13:14:53.725429 #1] INFO -- : > cd /var/www/discourse && su discourse -c 'bundle exec rake db:migrate'
rake aborted!
ArgumentError: wrong number of arguments (given 0, expected 1)
/var/www/discourse/lib/plugin/instance.rb:185:in `register_editable_user_custom_field'
/var/www/discourse/plugins/discourse-test-information/plugin.rb:18:in `block in activate!'
/var/www/discourse/lib/plugin/instance.rb:507:in `block in notify_after_initialize'
/var/www/discourse/lib/plugin/instance.rb:505:in `each'
/var/www/discourse/lib/plugin/instance.rb:505:in `notify_after_initialize'
/var/www/discourse/config/application.rb:228:in `each'
/var/www/discourse/config/application.rb:228:in `block (2 levels) in <class:Application>'
/var/www/discourse/lib/plugin.rb:6:in `initialization_guard'
/var/www/discourse/config/application.rb:228:in `block in <class:Application>'

Could anyone give my a hint what changed and how i need to adapt my code?

Thanks and regards,
Michael

1 Like

I found the answer: Add a custom per-user setting in a plugin

The first post was properly updated and i need to update my line to:

register_editable_user_custom_field [:myfield, myfield : {}]

paresy

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.