Skip to content

Commit

Permalink
Fix the check on select2 translations asset existence
Browse files Browse the repository at this point in the history
In environment expecting precompiled assets `Rails.application.assets`
is `nil` and we should fall back on checking the manifest.

(cherry picked from commit 8f997be)
  • Loading branch information
elia committed Jan 5, 2024
1 parent 4daeeff commit 7cc413c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions backend/app/views/spree/admin/shared/_js_locale_data.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
<script data-hook='admin-custom-translations'>
</script>

<% if I18n.locale != :en && I18n.locale %>
<% select2_locale_path = "solidus_admin/select2_locales/select2_locale_#{I18n.locale}" %>
<%= javascript_include_tag select2_locale_path, data: {turbolinks_track: 'reload'} if Rails.application.assets.find_asset(select2_locale_path) %>
<% select2_locale_path = "solidus_admin/select2_locales/select2_locale_#{I18n.locale}.js" %>
<% if I18n.locale != :en && I18n.locale && (
Rails.application.assets&.find_asset(select2_locale_path) || # compiled on the fly
Rails.application.assets_manifest.assets[select2_locale_path] # precompiled
) %>
<%= javascript_include_tag select2_locale_path, data: {turbolinks_track: 'reload'} %>
<% end %>

0 comments on commit 7cc413c

Please sign in to comment.