Rails asset pipeline solution for IE 4096 selector/stylesheet limit

We have an automated (albeit somehow awkward) solution working in production for a Rails 3.1 app with asset pipeline in place. Ryan already referenced the solution in his question but I try to come up with a more comprehensive answer. The asset pipeline pipes an asset through different Sprocket engines. So you might have e.g. … Read more

What sprockets mean in rails

Sprockets is a Ruby library for compiling and serving web assets. Sprockets allows to organize an application’s JavaScript files into smaller more manageable chunks that can be distributed over a number of directories and files. It provides structure and practices on how to include assets in our projects. Using directives at the start of each … Read more

require_tree argument must be a directory in a Rails 5 upgraded app

I finally figured it out. So because I am doing the upgrade, RailsDiff didn’t tell me that I was missing something. So the error message wasn’t incorrect, however, what I forgot to do was to create an empty directory. In my app/assets/javascripts/cable.js, I had the following: //= require_tree ./channels However, I forgot to actually create … Read more

Rails 3.1 is very slow in development-mode because of assets, what to do?

Take a look at https://github.com/wavii/rails-dev-tweaks. Rails is running all of the to_prepare hooks on every Sprockets asset request in development mode. This includes things like auto-(re)loading your code, and various gems sneak work in there too. rails-dev-tweaks disables to_prepare & reloading on any asset request (and a few others – read the first part of … Read more

Rails 3.1 Sprockets require directives – is there a way to exclude particular files?

This is possible with Sprocket’s new stub directive which is available in Sprockets v2.2.0 and up. However, Rails 3.2 will only ever use Sprockets v2.1.3 which does not have this feature. As of now, the current Edge Rails has the stub directive and it will officially be in Rails 4.0 and above. Usage: //= require … Read more

How do I use reference images in Sass when using Rails 3.1?

The following should do the trick: .button.checkable { background-image: url(image_path(‘tick.png’)); } Rails in fact provides a bunch of helpers to reference the assets: image-url(‘asset_name’) audio-path(‘asset_name’) In general [asset_type]-url(‘asset_name’) #Becomes url(‘assets/asset_name’) [asset_type]-path(‘asset_name’) #Becomes ‘assets/asset_name’ asset_type may be one of the following: image, font, video, audio, javascript, stylesheet

After gem update: test fail with “Asset was not declared to be precompiled in production”

Long Answer + Explanation I think the correct fix is to add the file to the precompiled assets, as recommended by the error message. Maybe that isn’t fixing the issue for you because you’ve got an erb file that needs to be rendered at run time. I imagine if the file was a static json … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)