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

Turbo prefetches set the current_team inadvertently #917

Open
pascallaliberte opened this issue Sep 21, 2024 · 0 comments
Open

Turbo prefetches set the current_team inadvertently #917

pascallaliberte opened this issue Sep 21, 2024 · 0 comments

Comments

@pascallaliberte
Copy link
Member

By default, Turbo prefetches links on hover to add more snapiness to the application.

This can be disabled application-wide by adding the following line to the head, for example, in an application's local app/views/layouts/_head.html.erb file:

<meta name="turbo-prefetch" content="false">

current_team is a global property that helps disambiguate a page's team context when the team is neither in the URL as param nor discoverable by looking at a resource's member action (e.g. #show) when the resource has a link back to its team. Since most resources in BT are tied to a Team by default, that's usually not a problem, and we even have better access to the current team in views via the @team property. Even deeply-nested resources will have access to the global @team property, because of the way loads_and_authorizes_resource is configured.

current_team is set on each page view, by default, through the ensure_onboarding_is_complete in bullet_train/app/controllers/concerns/account/controllers/base.rb, just to be sure.

The combination of an automatic current_team update and turbo prefetch automatically visiting a link can add some surprises.

An example of a surprise is detailed in issue #916, where the ability.rb file is evaluated based on a stale current_team, set in a prior request compared to the current_team of the current page's team context.

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