Attempting to access a non preloaded custom field, this is disallowed to prevent N+1 queries

This old problem has re-appeared and I can’t yet understand why it’s happening.

Attempting to access a non preloaded custom field, this is disallowed to prevent N+1 queries.

1 Like

Ah sorry, I’m getting closer to the issue:

plugins/discourse-zspace/plugin.rb:22:in block (2 levels) in activate!’`

and this code

add_to_serializer(:topic_list_item, :zspace_upload) {

    if object.custom_fields['zspace_upload']

I resolved by adding this line in front of that block:

TopicList.preloaded_custom_fields << "zspace_upload" if TopicList.respond_to? :preloaded_custom_fields

2 Likes