0
votes

rails beginner here

I am trying to set an app to production but having big issues with the asset pipeline. Under development every asset is generated under /assets/blabla.extension

However, I am running nginx and when running rake assets:precompile it creates assets under /public/assets as it should. But when I visit my app it generates urls like /application.css and not /assets/application-digestq12343.css as it should.

I think there is an easy fix to this problem.. but I cannot find it. Please help me!

Update: From the documentation I read that Sprockets "default" is /assets but it certainly isn't in my application. I use the latest version of rails. Can the documentation be outdated? http://edgeguides.rubyonrails.org/asset_pipeline.html

Even if I add config.assets.prefix = "/assets" to my production it would still mean that I would not load the assets since the digest would be missing.

1
Did you run production env with rails s or with external web server?user2895892
External I use nginx, I did some changes and used the rake task to build assets and suddently it just worked and the urls changed. Weird, I am not sure what fixed it. :pMs01
It seems you had to restart your rails server after assets are recompiled. Production enviroment, you know, it should be restarted after any trifle :) I could reproduse your situation if I run production server without assets compiled, recompile assets, and refresh the web page without restarting the server.user2895892
Yeah that was probably it. I first ran rake assets:precompile but that didn't work and I had to run bunle exec rake assets:precompile RAILS_ENV=production. But thanks for your help any way :)Ms01

1 Answers

1
votes

I believe this is the same problem I was experiencing. Instead of using url()in your css (or scss), use asset-data-url() and add config.assets.enabled = true to your application config file. Then, rake assets:precompile before you push.