Ask A Question


You’re not receiving notifications from this thread.

How can I get correct path of image (Production env) in Controller js (StimulusJs file) of Rails 7 app?

Hoang Thi Hien asked in Rails

I am using = <img src="/assets/Answer_${draggableElementBrand}.png"> to add element when a action is triggered. It works well in development but when I deploy it in Production, it's failed to load the image's path because the correct image's path is hashed. Do you have any idea or trick to get the correct path in this case? I am using Rails with ESbuild. Thank you so much.


SPAM comment reply, do not click the link

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,038+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.