3 ms·
Thanks, yoinking this for Appointment Reminder. In the spirit of creating wealth through exchange: https://gist.github.com/721114 https://gist.github.com/7211
by patio11 16y ago
Thanks, yoinking this for Appointment Reminder.
In the spirit of creating wealth through exchange:
https://gist.github.com/721114 https://gist.github.com/721114
A frequent problem I have is using CSS files which include http:// http:// linked background images, which will pass through every test with flying colors and then trigger prominent mixed-content security warnings in a browser I very seldom use. Slap this code in your initializers directory and you never have to worry about it again.
Just write your stylesheet_link_tag as normal, and then include :cache => request.ssl? ? "foo-secure" : "foo-standard"
Bonus: the included code also minimizes CSS and JS files in production, saving you page load time.
- stephencelis 16y agoCouldn't you just use protocol-relative URLs in your CSS files? (Or for that matter, absolute paths.)
- hboon 16y agoThe minimizing is good, but doesn't using a path like //example.com/my-image.jpg instead of http://example.com/my-image.jpg http://example.com/my-image.jpg fix the issue with http/https?
- patio11 16y agoThat works if you can enforce that 100% of the time, against all CSS loaded by your site. The first time you forget it in e.g. a lightbox script you add to get used on a landing page whose implementation you didn't even glance at, your registration page will break. This has cost me thousands of dollars before, so I enforce assumptions like "there are no http:// http:// urls in my CSS files" in code.
- mnutt 16y agoHow about part of your test suite that just greps for http:// http:// in public//*.css and fails CI if it finds anything?