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

Bug: Incorrectly resolved scopes due to the caching #252

Open
swilgosz opened this issue Dec 4, 2023 · 0 comments
Open

Bug: Incorrectly resolved scopes due to the caching #252

swilgosz opened this issue Dec 4, 2023 · 0 comments
Labels

Comments

@swilgosz
Copy link
Sponsor Member

swilgosz commented Dec 4, 2023

Background

When you have two scopes used, in the single view rendering, and you'll use path to the scope file instead of a class, you'll get only the first scope loaded, because of the caching.

Checking the code of the scope builder shows, that it allows to properly recognize the scope by file path, but because of caching, it falls back to the last defined.

image

To Reproduce

TODO: Link the sample App.

I have the app having 2 scopes in use:

 scope(
    "shared/forms/input",
    f: f,
    field_name: :username,
    errors: errors(:username)
      ).render("shared/forms/text_field")
scope('shared/flash', flash: _context.flash).render('layouts/flash_msg')

When I use both used on the same page document, it appears, that the code is tried to be loaded with the first loaded scope class.
Flash Message#visible? - is called on the forms/input scope definition, because:

  1. Flash is called in the layout (resolved later)
  2. the form_input is used in the view partial, which is resolved first, to be injected into the layout

image (1)

**NOTE: ** This is not a case if you pass ScopeClass as an argument.

QuickFix: hanamimastery/app@1dadcbf

Expected behavior

I expect the scope builder to properly resolve scopes, no matter if I pass class name, or the file path as argument, and not matter about the ordering of execution.

Your environment

  • Affects my production application: YES
  • Ruby version: 3.2.2
  • OS: All
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant