Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Template digest error #472

Open
corylown opened this issue Sep 1, 2016 · 8 comments
Open

Template digest error #472

corylown opened this issue Sep 1, 2016 · 8 comments
Assignees
Labels

Comments

@corylown
Copy link
Contributor

corylown commented Sep 1, 2016

Seeing this error in the log occasionally.

08:49:04 ERROR: Couldn't find template for digesting: catalog/item_options_download_

I think it has to do with the way templates are being called: app/views/catalog/_item_options_download.html.erb

<%= render partial: 'item_options_download_' + @document.display_format, locals: local_assigns %>

It may happen when @display_format is null?

@corylown corylown added the bug label Sep 1, 2016
@seanaery seanaery self-assigned this Sep 1, 2016
@seanaery
Copy link
Contributor

seanaery commented Sep 1, 2016

@corylown Looks like that's indeed the issue.

@seanaery
Copy link
Contributor

seanaery commented Sep 1, 2016

@corylown Strangely, I haven't been able to replicate this error in my local app/log, even with blank or garbage display_format values. But it definitely looks like adding a check for that download partial should do the trick.

@corylown
Copy link
Contributor Author

corylown commented Sep 1, 2016

@seanaery you might have to turn caching on in development to see the error.

In config/environments/development.rb update this line to 'true' to turn caching on:

config.action_controller.perform_caching = true

Turn this back to false and clear the cache after to avoid weird issues later ;-)

@corylown
Copy link
Contributor Author

corylown commented Sep 2, 2016

Looks like a Rails bug and not something we can easily fix. Doesn't cause any fatal errors.

rails/rails#19198

@seanaery
Copy link
Contributor

seanaery commented Sep 2, 2016

Agreed -- I've tried several workarounds but none actually work. Only solution would be to refactor those partials so they don't use interpolated strings for partial names. The costs of doing that probably outweigh the benefits.

@seanaery
Copy link
Contributor

seanaery commented Sep 2, 2016

To document the workarounds I tried...

Appears correctly to user but logs error

<%= render partial: 'item_options_download_' + @document.display_format, locals: local_assigns %>
ERROR: Couldn't find template for digesting: catalog/item_options_download_

<% format_download_partial = 'item_options_download_' + @document.display_format %>
<%= render partial: format_download_partial, locals: local_assigns %>
ERROR: Couldn't find template for digesting: format_download_partials/format_download_partial

<%= render partial: 'catalog/item_options_download_' + @document.display_format, locals: local_assigns %>
ERROR: Couldn't find template for digesting: catalog/item_options_download_

<% format_download_partial = 'item_options_download_' + @document.display_format %>
<%= render partial: format_download_partial.to_s, locals: local_assigns %>
ERROR: Couldn't find template for digesting: to_s/to_

Error for User

<%= render partial: 'catalog/item_options_download_#{@document.display_format}', locals: local_assigns %>
The partial name (catalog/item_options_download_#{@document.display_format}) is not a valid Ruby identifier; make sure your partial name starts with underscore, and is followed by any combination of letters, numbers and underscores.

@corylown
Copy link
Contributor Author

corylown commented Sep 2, 2016

You need to use double quotes for Ruby string interpolation to work. But that still probably doesn't fix the core issue.

@seanaery
Copy link
Contributor

seanaery commented Sep 2, 2016

Oh, that's right--thanks. Indeed that also results in an error in the log:
<%= render partial: "catalog/item_options_download_#{@document.display_format}", locals: local_assigns %>
ERROR: Couldn't find template for digesting: catalog/item_options_download_#{@document.display_format}

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

No branches or pull requests

2 participants