Custom plugin: cannot add to serializer

Hi.
I’m trying to include User admin (true/false) field to BasicUserSerializer, so I could use it, i.e., on About page.

#plugin.rb
after_initialize do
  add_to_serializer(:basic_user, :admin) do
    object.admin
  end
end

But anytime I add it in the plugin like this, all other pages fail to load, except About page (and also I can actually see that parameter added successfully), receiving ActiveModel::MissingAttributeError in ListController#latest - missing attribute: admin.

How to avoid this?

1 Like

Did you manage to do this?