Questions tagged [sprockets]

Sprockets is a Ruby library that preprocesses and concatenates JavaScript and CSS source files.

Sprockets takes any number of source files and preprocesses them line-by-line in order to build a single concatenation.

Specially formatted lines act as directives to the Sprockets preprocessor, telling it to require the contents of another file or library first or to provide a set of asset files (such as images or stylesheets) to the document root.

Sprockets attempts to fulfill required dependencies by searching a set of directories called the load path.

807 questions
15
votes
3 answers

How do you write DRY, modular coffeescript with Sprockets in Rails 3.1?

I'm in the early stages of trying to write some sensible Javascript. I want to namespace basically everything under the name of my application to avoid globals as much as possible, but still give me a way to access functions declared around the…
15
votes
1 answer

Remove Sprockets from Rails

How do you remove Sprockets from Rails? I've.. removed all the Sprockets Gems. removed all the config.assets.* from initializers, etc.. Still, Rails is looking for…
GN.
  • 8,672
  • 10
  • 61
  • 126
15
votes
1 answer

Asset application.css is not declared but it is declared in manifest

I got this error: ActionView::Template::Error (Asset `application.css` was not declared to be precompiled in production. Declare links to your assets in `app/assets/config/manifest.js`. //= link application.css and restart your server): Rails…
15
votes
0 answers

Rails Assets Best Practices

I'm new to Rails, and having trouble figuring out the best way to organize my assets. The purpose of this question is to collect my thoughts, solicit input, and evolve the document over time - perhaps it can be a Rails Guide someday. (The Rails…
odigity
  • 7,568
  • 4
  • 37
  • 51
14
votes
4 answers

Why does stylesheet_link_tag not link to /assets in production?

I just did the first deploy for a new Rails 3.1 application, but the assets don't seem to work correctly. I'm precompiling everything upon deploy, and it turns up in public/assets like expected. However, the output of for example stylesheet_link_tag…
Marten Veldthuis
  • 1,870
  • 1
  • 16
  • 15
14
votes
4 answers

Rails local asset:precompile - is there an automated way to check for changes?

I ran into problems with asset pre-compilation during deploys, so I opted to go for local pre-compilation and check in the resulting files to my source tree. I don't really have any problems with that approach, except that sometimes I forget to run…
Mark G.
  • 3,176
  • 1
  • 27
  • 29
14
votes
4 answers

Accessing images on production, from javascript, in Rails 4

It appears that now in Rails 4 using asset pipeline and the sprocket-rails gem, when images are processed, their filename is appended with an md5 fingerprint like css and javascript. While this makes sense because md5 fingerprints are awesome, it…
Bryan Ashley
  • 971
  • 7
  • 22
13
votes
2 answers

How do I add asset search paths to Sprockets based on a wildcard subdomain in rails 3.1?

The Rails Asset Pipeline guide instructs you to use config.assets.paths in config/application.rb but I don't have access to the request's subdomain at this point. I'd like to be able to prepend an extra path (for the current request only) based on…
13
votes
6 answers

Rails 3.1 and sprockets make it harder to debug using firebug?

In Rails 3.1, Sprockets are used to manage assets and package them into a single file. Which, in general, is not such a bad idea. As quoted from an external source, which explains the issue at hand: A problem with this approach is that it could…
Christian Fazzini
  • 19,613
  • 21
  • 110
  • 215
13
votes
1 answer

Rails asset pipeline: how to create custom manifest file

I am trying to make a custom manifest javascript file seperate from application.js. I've take the code from application.js and pasted it into a new file I've called "other_manifest.js" and placed in the assets/javascrips directory. Here is the…
13
votes
2 answers

How to override single files from gem assets for assets:precompile?

Situation I use a gem that brings its own JavaScript and stylesheet assets. This gem uses a standard application.js and application.css manifest to require all its assets: [gem]/app/assets/javascripts/gem_name/application.js require_tree…
Robert
  • 1,936
  • 27
  • 38
12
votes
2 answers

Exclude certain assets from pipeline in development environment?

I would like to somehow prevent certain assets from being included in the asset pipeline in the development environment. So far, I have tried the following: # app/assets/javascripts/application.js.erb <% if Rails.env.production? %> //= require…
David Tuite
  • 22,258
  • 25
  • 106
  • 176
12
votes
4 answers

How to ignore Rails 3 assets from log

Possible Duplicate: How to disable logging of asset pipeline (sprockets) messages in Rails 3.1? is possible to hack logger in Rails3 to ignore requests for assets? It is maddness to find something in log, when it is full of Started GET…
Schovi
  • 1,960
  • 5
  • 19
  • 33
12
votes
3 answers

Where to put Galleria (jQuery image gallery framework) in Rails 3.1 Asset Pipeline?

I'm a bit confused as to where to put a jQuery framework like Galleria in Rails 3.1's new Asset Pipeline? I know it, technically, should go into /vendors/assets/javascripts but, it is my understanding that, the Galleria folder with the jQuery &…
Meltemi
  • 37,979
  • 50
  • 195
  • 293
11
votes
2 answers

How to require assets only for development environment

I'm using the assets pipeline from Rails 3.1 and I want to include some javascript files only if it's the development environment. Example: //= require application/jquery //= require application/jquery_ujs // next ones only for development…