Questions tagged [asset-pipeline]

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages and pre-processors such as CoffeeScript, Sass and ERB.

The asset pipeline is a feature added to Ruby on Rails 3.1 to provide improved organization and processing for JavaScript, stylesheets, and images. There also exists a Grails plugin named asset-pipeline that provides equivalent functionality to applications developed for this framework.

These assets can be separated into folders under app/assets/ for those that are application-specific, lib/assets/ for assets shared across multiple applications, and vendor/assets/ for third-party assets. Each of those folders would have subfolders like javascripts/, stylesheets/ and images/.

This is meant to eliminate what Ruby on Rails creator David Heinemeier Hansson calls the "junk drawer" approach of putting all JavaScript code (for example) in the same folder, regardless of source.

Additionally, as Ryan Bigg has documented:

The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, SCSS and ERB. -- Rails Guides

3569 questions
52
votes
4 answers

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

Since I updated several gems all tests fail with the error: ActionView::Template::Error: Asset was not declared to be precompiled in production. Add Rails.application.config.assets.precompile += %w( favicons/manifest.json.erb ) to…
Marty
  • 2,132
  • 4
  • 21
  • 47
50
votes
4 answers

Rails 3.1: Determine if asset exists

Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths. My app goes and fetches images from a remote server on a Resque queue;…
Jim Zajkowski
  • 987
  • 1
  • 7
  • 13
50
votes
4 answers

Rails 3.1 serving images from vendor/assets/images

I am trying to put some external images (used by a jQuery plugin) to vendor/assets/images in my Rails 3.1 app. Problem is that when I try something like: <%= image_tag "ui-bg_flat_75_ffffff_40x100.png" %> I get an error: No route matches [GET]…
Slobodan Kovacevic
  • 6,848
  • 3
  • 29
  • 33
49
votes
9 answers

sass-rails helpers "image-url", "asset-url" are not working in rails 3.2.1

I am on 3.2.1, with sass-rails-3.2.4 and sass-3.1.15... The documentation for the asset pipeline says: asset-url("rails.png", image) becomes url(/assets/rails.png) image-url("rails.png") becomes url(/assets/rails.png) ... So I made the following…
patrick
  • 9,290
  • 13
  • 61
  • 112
49
votes
3 answers

Rails 3.1 asset precompilation - include all javascript files

I want Rails 3.1 to pick up more of my assets for precompilation. In particular, the default matcher for compiling files doesn't add .js files from vendor/assets/javascripts. I can just add the assets to the config.assets.precompile list, but this…
Peter
  • 127,331
  • 53
  • 180
  • 211
49
votes
2 answers

Route helpers in asset pipeline

using Rails 3.1.0.rc4, I'm trying to access a route helper in a javascript file (event.js.erb in this case) and it seems like they are not loaded at that moment. When requesting the merged /assets/application.js file, I get: throw Error("NameError:…
tbuehlmann
  • 9,032
  • 5
  • 27
  • 33
49
votes
8 answers

Rails App Not Serving Assets in Production Environment

My app works fine when run in development environment. In production (rails server -e production), the browser can't access the css and js files and on the console there are messages like: I, [2013-07-27T21:00:59.105459 #11449] INFO -- : Started…
septerr
  • 6,445
  • 9
  • 50
  • 73
46
votes
4 answers

Uncompile Development Asset Pipeline

I was compiling my asset pipeline for my production environment and it did for all my environments. How can I uncompile my asset pipeline for my development environment? I have checked my config/development environment and cannot find a fix. Thanks…
Kyle C
  • 4,077
  • 2
  • 31
  • 34
46
votes
4 answers

How can I get the Rails asset pipeline to produce source maps?

I'd like to have Rails produce source maps alongside the compiled coffeescript/minified JS, for better error logging. There doesn't seem to be comprehensive documentation on the net on how to do this, yet, though. Has anyone done this? I'm on Rails…
Vincent Woo
  • 2,650
  • 1
  • 20
  • 21
43
votes
9 answers

Disable Asset Minification in Rails Production

In order to debug javascript in my heroku production environment, I need to disable asset compression (or at least compression of javascript). I tried config.assets.compress = false along with config.assets.debug = true, and the compressed assets…
Jack R-G
  • 1,778
  • 2
  • 19
  • 25
43
votes
3 answers

How to debug a Rails asset precompile which is unbearably slow

I'm working on a Rails 3.2 project and the assets have increased a fair bit in recent months although I wouldn't consider the project to be large. The assets consist of JS (no coffee-script), and SASS files; we've quite a few images but they've been…
andyroberts
  • 3,458
  • 2
  • 37
  • 40
41
votes
3 answers

Rails Active Admin css conflicting with Twitter Bootstrap css

I'm somewhat new to the Rails asset pipeline so I might be doing something wrong. I'm trying to use Active Admin for my backend and twitter bootstrap css for my front end application. I added the bootstrap.css to /app/assets/stylesheets then also…
RailsTweeter
  • 1,625
  • 3
  • 18
  • 33
39
votes
8 answers

The asset "logo.png" is not present in the asset pipeline

In Rails 5.1.3 I change logo file in app/assets/images Then error don't know what to fix. Any one know ? The asset "logo.png" is not present in the asset pipeline. Already try restart rails, rails clean, rails or rails assets:precompile Here my…
PKul
  • 1,691
  • 2
  • 21
  • 41
39
votes
5 answers

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

I just upgraded my app from Rails 4.2.7 to Rails 5.0.0.1. I used RailsDiff to make sure I had everything covered and I believe I did. So far everything has worked well up until the loading of my app. Now I am seeing this…
marcamillion
  • 32,933
  • 55
  • 189
  • 380
37
votes
4 answers

blueprint/screen.css isn't precompiled

I've been following along Michael Hartl's excellent RoR Tutorial, but I'm using RoR 3.1. I am a newbie to RoR 3.1 and need help related to assets pipeline. Here is my problem: Before continuing to section 5.3, I thought I'd like to push to Heroku…
John Indra
  • 473
  • 1
  • 5
  • 6