I have a products model that has many images via Active Storage
class Product < ApplicationRecord
has_many_attached :images
end
My products/show view shows the first image as a link to a modal that shows all the other images:
- if @product.images.present?
= link_to image_tag(@product.images.first, class: "img-fluid"), "#", data: {toggle: "modal", target: "#images"}
/ or
= link_to image_tag(url_for(@product.images.first)), "#", class: "img-fluid", data: {toggle: "modal", target: "#images"}
#images.modal
.modal-dialog
.modal-content
.modal-body
.carousel-inner
.carousel-item.active
= image_tag = @product.images.first, class: 'd-block w-100'
- @product.images.drop(1).each do |image|
.carousel-item
= image_tag image, class: 'd-block w-100'
a.carousel-control-prev data-slide="prev" href="#image_controls" role="button"
span.carousel-control-prev-icon
a.carousel-control-next data-slide="next" href="#image_controls" role="button"
span.carousel-control-next-icon
It works well for a few minutes. But somehow, ?locale=en
gets added to the image link from Active Storage after a few minutes so that the image does not show anymore.
<img src="/rails/active_storage/blobs/longstring/image_file.jpg">
becomes
<img src="/rails/active_storage/blobs/longstring/image_file.jpg?locale=en">
My routes file:
scope "(:locale)", locale: /en|ja/ do
resources :products
How do I prevent rails from adding locale=en
to the image link?