Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReadMark.readable_classes is nil until the first use #115

Open
ishields opened this issue Mar 12, 2020 · 0 comments
Open

ReadMark.readable_classes is nil until the first use #115

ishields opened this issue Mar 12, 2020 · 0 comments

Comments

@ishields
Copy link

ishields commented Mar 12, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant