Skip to content

ReadMark.readable_classes is nil until the first use #115

@ishields

Description

@ishields

I'm noticing in development ReadMark.readable_classes is nil. It's not till I made a related call that it got defined with User as a readable type.

ReadMark.readable_classes => nil
User.first.have_read?(Article.last)  => false
ReadMark.readable_classes => [Article(id: integer ... )]

This resulted in some different behavior in console/development than what I could expect in the actual app. For example in the console:

def setup_new_reader
        (ReadMark.readable_classes || []).each do |klass|
          klass.mark_as_read! :all, for: self
        end
end

would not initially do anything, until after the .have_read? call.

Should ReadMark.readable_classe be you need to setup in a config or something?

I think this may be related to eager loading in development. If Article is not loaded before a User is created (which can happen all the time in development), then this unintentional behavior will happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions