Note that there are some explanatory texts on larger screens.

plurals
  1. USjshkol
    primarykey
    data
    text
    plurals
    1. This table or related slice is empty.
    1. COThanks @Amala, looks interesting. In the past I have just let CloudFront load assets directly from my app server. It looks like asset_sync pushes the compiled assets to S3 and then I assume you just point your CDN at your S3 bucket. Have you noticed a big improvement vs. letting the CDN load up it's cache directly from your app server?
      singulars
    2. COYou are correct that the initializers work when the web server boots up but you're missing the point, I need access to those config variables **DURING** asset precompilation. As I mentioned in my question the Rails convention in this circumstance is to set `config.assets.initialize_on_precompile = true`, however this breaks asset compilation on Heroku because the dyno that does the compilation is not granted access to the database. The challenge is running the initializer I want without initializing anything that connects to a DB. @Alg offered a viable solution above.
      singulars
    3. COThanks @Alg, I've actually been using a variation of the same strategy. Instead of adding the `require` line to _each_ asset that makes use of the load_config initializer I just created a **single dummy asset** (load_app_config.js.erb) that contains _only_ the `require` line. Then I just do an asset require for that file at the top of each of my asset manifest files. As long as the dummy asset is loaded before the assets making use of the initializer everything works fine. I was hoping there was a less hacky solution but since you're answer is so close to what I used I'll accept. Thx!
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload