Rails 5 resources bring 404 back to development
I know this question is being asked a lot, but I am losing my mind here. I started building an application using Rails 5. I deployed to AWS EB and installed the env for development. But my assets are not loading. Getting 404 I have implemented asterisks require 'rails/all'
in both my application.rb file and also run rake assets:precompile
. I've also tried all configurations config.asset
in development.rb:
config.assets_compile
config.public_file_server.enabled
config.assets.digest
config.assets.enabled
The nginx error log fills up for each of my assets. The path is wrong. I did not put my assets in /var/app/current/public
, I put them in /var/app/current/app/assets
. At some point I got it from there (can't remember how), but it still doesn't work:
2017/07/28 01:16:15 [error] 2994#0: *1387 open() "/var/app/current/public/assets/merck-logo.png" failed (2: No such file or directory), client: 76.218.103.88, server: _, request: "GET /assets/merck-logo.png HTTP/1.1", host: "merckcoupons-dev1.dv3ww3wmii.us-west-1.elasticbeanstalk.com", referrer: "http://merckcoupons-dev1.dv3ww3wmii.us-west-1.elasticbeanstalk.com/circular"
The crazy thing is, I just did it with another app not too long ago and opened it up as a guide. I have been working on the internet for many hours and I cannot figure it out. Any help would be appreciated!
source to share
When accessing images using the helper, image_tag
only the filename and path are not. Rails will use the file in app/assets/images
the development environment and then use it public/assets/IMAGE_NAME_FINGER_PRINT.ext
in other environments (after precompiling).
See: http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
For example:
THE GOOD: <%= image_tag 'rails.png' %>
BAD: <%= image_tag '/assets/rails.png' %>
source to share