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
430
votes
20 answers

Rails 4: how to use $(document).ready() with turbo-links

I ran into an issue in my Rails 4 app while trying to organize JS files "the rails way". They were previously scattered across different views. I organized them into separate files and compile them with the assets pipeline. However, I just learned…
emersonthis
  • 32,822
  • 59
  • 210
  • 375
389
votes
29 answers

Using Rails 3.1, where do you put your "page specific" JavaScript code?

To my understanding, all of your JavaScript gets merged into 1 file. Rails does this by default when it adds //= require_tree . to the bottom of your application.js manifest file. This sounds like a real life-saver, but I am a little concerned…
378
votes
14 answers

How can I disable logging of asset pipeline (sprockets) messages in Ruby on Rails 3.1?

Sprockets tends to be quite verbose in the (dev) log by default under Ruby on Rails 3.1 (RC1): Started GET "/assets/application.css" for 127.0.0.1 at 2011-06-10 17:30:45 -0400 Compiled app/assets/stylesheets/application.css.scss (5ms) (pid…
355
votes
13 answers

Using fonts with Rails asset pipeline

I have some fonts being configured in my Scss file like so: @font-face { font-family: 'Icomoon'; src: asset-url('icoMoon.eot?#iefix', font) format('embedded-opentype'), asset-url('icoMoon.woff', font) format('woff'), …
rctneil
  • 7,016
  • 10
  • 40
  • 83
281
votes
14 answers

rails 3.1.0 ActionView::Template::Error (application.css isn't precompiled)

I made a basic rails app with a simple pages controller with an index function and when I load the page I get: ActionView::Template::Error (application.css isn't precompiled): 2: 3: 4: Demo 5: <%=…
Chris Muench
  • 17,444
  • 70
  • 209
  • 362
202
votes
7 answers

config.assets.compile=true in Rails production, why not?

The default Rails app installed by rails new has config.assets.compile = false in production. And the ordinary way to do things is to run rake assets:precompile before deploying your app, to make sure all asset pipeline assets are compiled. So…
jrochkind
  • 22,799
  • 12
  • 59
  • 74
182
votes
30 answers

Failed to decode downloaded font, OTS parsing error: invalid version tag + rails 4

I am doing assets pre-compile, and running the application in production mode. After compilation when I load the my index page I got followings warnings in the chrome console: Failed to decode downloaded font:…
Deepti Kakade
  • 3,053
  • 3
  • 19
  • 30
167
votes
3 answers

Using Rails 3.1 assets pipeline to conditionally use certain css

I’m in the process of building my first solo Rails app using Rails 3.1.rc5. My problem is that I want to have my site render the various CSS files conditionally. I’m using Blueprint CSS and I’m trying to have sprockets/rails render screen.css most…
talon55
  • 2,023
  • 3
  • 15
  • 10
151
votes
9 answers

No route matches [GET] /assets

I have a Rails app that I'm trying to test in the production environment. I ran RAILS_ENV=production rake assets:precompile which generated all of my assets in /public/assets. The problem is that when I start my app w/ RAILS_ENV=production rails s…
Kyle Decot
  • 20,715
  • 39
  • 142
  • 263
124
votes
18 answers

Rails 4: assets not loading in production

I'm trying to put my app into production and image and css asset paths aren't working. Here's what I'm currently doing: Image assets live in /app/assets/images/image.jpg Stylesheets live in /app/assets/stylesheets/style.css In my layout, I…
emersonthis
  • 32,822
  • 59
  • 210
  • 375
104
votes
13 answers

ExecJS::RuntimeError on Windows trying to follow rubytutorial

UPDATE: Colin's suggestion of removing the line //= require_tree . has fixed the issue. I have wasted over 2 days trying to follow every suggestion out there and fix my issue. I am trying to follow the http://ruby.railstutorial.org book on windows…
user1687078
  • 1,353
  • 3
  • 10
  • 10
103
votes
7 answers

Rails 4 image-path, image-url and asset-url no longer work in SCSS files

Are we supposed to use something else aside from image-url and others in Rails 4? They return different values that don't seem to make sense. If I have logo.png in /app/assets/images/logo.png and I do the following, this is what I…
at.
  • 50,922
  • 104
  • 292
  • 461
100
votes
3 answers

Why did Rails4 drop support for "assets" group in the Gemfile

In Rails 3, gems used exclusively to generate assets in the asset pipeline were properly placed in the assets group of the Gemfile: ... # Gems used only for assets and not required # in production environments by default. group :assets do gem…
jemmons
  • 18,605
  • 8
  • 55
  • 84
89
votes
6 answers

Proper SCSS Asset Structure in Rails

So, I have an app/assets/stylesheets/ directory structure that looks something like this: |-dialogs |-mixins |---buttons |---gradients |---vendor_support |---widgets |-pages |-structure |-ui_elements In each directory,…
David Savage
  • 1,562
  • 2
  • 18
  • 35
78
votes
6 answers

Add a new asset path in Rails 3.1

Does anyone know how to add another folder to the asset pipeline in Rails 3.1? I'd like to serve app/assets/fonts the same way app/assets/images is served. Update: 5-7-2013 Just to add some clarification for future people who find this question to…
Andrew
  • 42,517
  • 51
  • 181
  • 281
1
2 3
99 100