Rails: problem locating asset following fly-deploy

Hi! I’m just trying to deploy a test Rails app and now get this error after what I thought was a successful fly-deploy:

“We’re sorry, but something went wrong.”

In the log file, I read that

ActionView::Template::Error (The asset "sparky-in-the-sink" is not present in the asset pipeline.

This is after I installed ‘sparky-in-the-sink.jpg’ into the Rails folder ‘app/assets/images’.

If I refer to the image with

<%= image_tag("sparky-in-the-sink", {:style => "width:300px;"}) %>

Everthing works ok when I start Rails in development on my localhost.

I guess this falls under the Rails 7 asset pipeline category which seems a complex topic.

I did find “Making Sense of Rails Assets · Fly” but I’m not sure this helped me make sense of my particular image problem.

Anyone have an idea on how to fix, or least learn more?

Thank you!

1 Like

Sounds like rails assets:precompile wasn’t run. Are you using a Dockerfile? Can you run Getting Started · Fly Docs to the point of the first deploy?

Oh yes in fact I’m pretty sure that’s exactly the tutorial I’ve been following. After adding turbo streams, I did rails db:migrate, and fly-deploy. I then tried adding the image I described above. Then I got the errors.

I do have a Dockerfile in the root of my project as per the tutorial.

Did you solve the issue? I’m having the exact same problem

Hi! Try to add this to your dockerfile before precompiling assets

RUN yarn build
RUN yarn build:css
# Precompiling assets for production without requiring secret RAILS_MASTER_KEY
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile

Ok yes @matiasleandronunez I do not have good access to that project now, but if I remember correctly my root problem was failure to use the Rails image_tag correctly… maybe inclusion of (or failure to include) the file extension, something dumb like that.

Thanks for the answers @tomb & @Alexey, however that didn’t seem to solve the issue in my case.

I have the default Dockerfile from the sample project that has the line
RUN SECRET_KEY_BASE=DUMMY ./bin/rails assets:precompile
but upon fly deploy I don’t see anything but the 404.html, 502.html etc in /public/assets when I ssh

Did you try to add this as I mentioned?

RUN yarn build
RUN yarn build:css

Does the following work locally?

bin/rails server -e production

@Alexey Yes, image fails to build.

@rubys It does, but displays the same behaviour.