You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm not sure that this is technically a bug but it does list extra dependencies for templates that are not actually dependencies. This occurs because of how the dependency tracker looks for render calls in templates.
I ran into this bug when I was using a decorator object that defined to_partial_path. I had in my view a render call like this <%= render MyDecorator.new(model_object) %> and I also had calls to the cache helper in the same template. When the cache helper was getting the dependencies to use for digesting, I saw in the log Couldn't find template for digesting: news/new. I was able to track this down to how the dependency tracker finds render calls and then processes them. The relevant code is here https://github.com/rails/rails/blob/v5.0.0.beta2/actionview/lib/action_view/dependency_tracker.rb#L118.
I am also going to submit a pull request with a fix for this issue. I believe this issue #21951 is related and is also will be fixed by the pull request.
To reproduce this problem:
create a new rails project
create a controller with an action (name doesn't matter) and the corresponding view template
run bundle exec rake cache_digests:dependencies TEMPLATE=that_template_name
=>["autokinds/autokind","static/ data-auto_kinds=",# static is the name of the controller I chose"ApplicationHelpers/ApplicationHelper","news/new"]
After the fix, running the cache_digests command on the same template will produce:
=>["employees/employee"]
This is matching the last render call, the scoped access of a record in the ApplicationHelper. I'm not sure that anyone actually uses that but it is a side-effect fix to prevent the 3rd dependency, "ApplicationHelpers/ApplicationHelper", from showing as a dependency.
The text was updated successfully, but these errors were encountered:
The HTML part has been fixed by #42458 and subsequent PRs.
For the constant refs, it still not quite fixed but ultimately the dependency tracker is understood as being best effort, so I don't think it's worth keeping this open, but people running into this issue are welcome to open a PR to fix these false positives.
I'm not sure that this is technically a bug but it does list extra dependencies for templates that are not actually dependencies. This occurs because of how the dependency tracker looks for render calls in templates.
I ran into this bug when I was using a decorator object that defined
to_partial_path
. I had in my view a render call like this<%= render MyDecorator.new(model_object) %>
and I also had calls to the cache helper in the same template. When the cache helper was getting the dependencies to use for digesting, I saw in the logCouldn't find template for digesting: news/new
. I was able to track this down to how the dependency tracker finds render calls and then processes them. The relevant code is here https://github.com/rails/rails/blob/v5.0.0.beta2/actionview/lib/action_view/dependency_tracker.rb#L118.I am also going to submit a pull request with a fix for this issue. I believe this issue #21951 is related and is also will be fixed by the pull request.
To reproduce this problem:
create a new rails project
create a controller with an action (name doesn't matter) and the corresponding view template
in the view template add the following erb:
run
bundle exec rake cache_digests:dependencies TEMPLATE=that_template_name
After the fix, running the cache_digests command on the same template will produce:
This is matching the last render call, the scoped access of a record in the ApplicationHelper. I'm not sure that anyone actually uses that but it is a side-effect fix to prevent the 3rd dependency, "ApplicationHelpers/ApplicationHelper", from showing as a dependency.
The text was updated successfully, but these errors were encountered: