refinery / refinerycms

An extendable Ruby on Rails CMS that supports Rails 6.0+
https://www.refinerycms.com/
MIT License
3.9k stars 1.26k forks source link

Some assets don't utilize asset pipeline, cause 404s #1287

Closed syelle closed 12 years ago

syelle commented 12 years ago

I've noticed many refinery-related assets 404 when I'm in my admin panel outside of a development environment. The difference between the ones that work and the ones that don't seem to be that the ones that do not work are not utilizing the asset pipeline properly.

These do not work: https://admin.tera.qa.enmasse.com/assets/refinery/carousel-right.png https://admin.tera.qa.enmasse.com/assets/refinery/carousel-left.png https://admin.tera.qa.enmasse.com/assets/refinery/ajax-loader.gif https://admin.tera.qa.enmasse.com/assets/wymeditor/skins/refinery/wymiframe.css?5282651692112581 https://admin.tera.qa.enmasse.com/assets/formatting.css?18938815493726824 https://admin.tera.qa.enmasse.com/assets/theme.css?11953640834117985 https://admin.tera.qa.enmasse.com/assets/wymeditor/skins/refinery/wymiframe.css?17024000154518804 https://admin.tera.qa.enmasse.com/assets/formatting.css?8155823824584488 https://admin.tera.qa.enmasse.com/assets/theme.css?9678781410283206 https://admin.tera.qa.enmasse.com/assets/refinery/tooltip-nib.png

These assets, however, work fine: http://tera-0.qa.enmasse-game.com/assets/c49bae9ab79da7a0b8a03b875c467a5c03baed2a/refinery/page-image-picker-b6b1f35ba383c32932afc0b0562c300b.js http://tera-1.qa.enmasse-game.com/assets/c49bae9ab79da7a0b8a03b875c467a5c03baed2a/wymeditor/skins/refinery/text_heading_1-9f5c2dd7f2ec54d8afc0d2650b549d06.png http://tera-0.qa.enmasse-game.com/assets/c49bae9ab79da7a0b8a03b875c467a5c03baed2a/wymeditor/skins/refinery/text_paragraph-a430a01e918a05f5a8a25c9bab624c1a.png

I poked around some code and what I found seem to corroborate the idea that these are failing due to lack of use of the asset pipeline. A few examples:

Core: https://github.com/resolve/refinerycms/blob/master/core/app/assets/javascripts/refinery/boot_wym.js.erb#L256 https://github.com/resolve/refinerycms/blob/master/core/app/assets/javascripts/refinery/admin.js.erb#L197 https://github.com/resolve/refinerycms/blob/master/core/app/assets/javascripts/refinery/interface.js.coffee#L37

Blog Engine (I can make a separate issue if you want one on that project as well): https://github.com/resolve/refinerycms-blog/blob/rails-3-1/app/assets/javascripts/refinery/blog/backend.js#L11

parndt commented 12 years ago

Thanks for reporting this! Now that the wymeditor script is .erb I guess we can just convert those to proper asset URLs.

simi commented 12 years ago

We need just convert it to use asset pipeline, not hardcoded url.

ugisozols commented 12 years ago

I tried to replace hardcoded images with <%= asset_path(...) %> but it still used regular assets like carousel-right.png instead of carousel-right.png-asdaasasdas9d90asd98 ones.

Btw, there was no 404's...

syelle commented 12 years ago

@ugisozols I only saw 404s in environments that were using the asset pipeline and specifying a custom config.assets.prefix in our environment file to add the git commit hash to our asset path (in an effort to expire all assets each build). If I remove that configuration entry, the assets stop throwing errors. It still doesn't create the proper URL as you indicated, however, which is really the root of the issue: if it were properly respecting the asset pipeline, my configuration change shouldn't break it.

ugisozols commented 12 years ago

@syelle can you try replacing one of the failing assets with <%= asset_path("...") %> and see if it resolves your issue.

syelle commented 12 years ago

@ugisozols I'll give it a try (hopefully soon). We actually removed the git hash from our asset path (and thus no longer need that config variable). I'll have to make changes to a branch to revert these changes, make your suggested changes, and test.

parndt commented 12 years ago

Would like to get this issue resolved in the next few days so that we can include it in 2.0

parndt commented 12 years ago

Totally about to pwn this issue!

parndt commented 12 years ago

HEADSHOT!