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
19
votes
4 answers

How to comment out rails 3.1 asset require statement

Is it possible to comment out this line in the new app/assets/application.js file? If so, how? //=require jquery_ujs I mean, it's already commented out to avoid being misconstrued as CoffeeScript or JavaScript, but it's obviously serving a purpose…
c3rin
  • 1,907
  • 15
  • 16
19
votes
1 answer

How can I run custom code before any asset precompile in Rails?

Something like (in an initializer): Sprockets.before_precompile do # some custom stuff that preps or autogenerates some asset files # that should then be considered in the asset pipeline as if they were checked in end Specifically, I'd like to…
btown
  • 2,273
  • 3
  • 27
  • 38
18
votes
4 answers

Sprockets::CircularDependencyError in Store#index

I am following the manual Agile Web Development with Rails 4th edition and I have a problem with sprocket css in rails 3.1. The code css is: http://media.pragprog.com/titles/rails4/code/rails31/depot_e/app/assets/stylesheets/application.css.scss If…
hyperrjas
  • 10,666
  • 25
  • 99
  • 198
18
votes
6 answers

SASS, Rails 3.1: Loading stylesheets in vendor/assets

I'm using SASS to load stylesheets in a Rails 3.1(sass-rails 3.1) app. For example, sass partials in app/assets/stylesheets are loaded using @import in application.sass - @import "pages/common" @import "pages/**/*" @import "jquery-ui.css" Now, I…
Akshay Rawat
  • 4,714
  • 5
  • 40
  • 65
18
votes
1 answer

How can I access image_path route helper inside a Rails 3 model?

I'm trying to use Sprockets' image_path method from within a Rails 3 model. I've tried including ActionView::Helpers::AssetTagHelper in my model and calling image_path but that does not work (undefined local variable or method 'config'). Any…
17
votes
3 answers

Avoid *.js.erb files by building all the asset_path values

So I want to avoid processing JavaScript files with ERB just so I can get a proper asset path to, say, an image. Currently, this seems like the popular approach: var myImage = "<%= asset_path('my_image') %>"; Which, of course, requires the…
Justin Searls
  • 4,789
  • 4
  • 45
  • 56
17
votes
6 answers

Sprockets File not Found Exception

I was trying out some sample applications for Rails. I created some controllers and pages. But when i try to access one of them i get an exception on the webpage: Sprockets::FileNotFound in Pages#home Showing…
Asker
  • 725
  • 1
  • 4
  • 14
17
votes
2 answers

Precompiling a .scss manifest file using Rails 3.1's asset pipeline

The release version of Rails 3.1 is having some weird issues with precompiling a sass manifest file with the extension scss. The weird thing is that the default manifest file application.scss compiles fine and I see it under public/assets/. However…
Anurag
  • 140,337
  • 36
  • 221
  • 257
17
votes
2 answers

Rails4 Sprockets; Asset logical path has no extension

I recently upgraded to Rails 4, and whilst running my request specs I started getting the following error: Failure/Error: Unable to find matching line from backtrace Sprockets::ArgumentError: Asset logical path has no extension:…
tblakey89
  • 656
  • 2
  • 9
  • 18
17
votes
3 answers

Disable Sprockets asset caching in development

I'm using Rails 3.2.13 and the Rails Asset Pipeline. I want to use the Asset Pipeline so I can use SASS and CoffeeScript and ERB for my assets and have the Pipeline automatically compile them, so I cannot turn off the pipeline in development. I am…
Old Pro
  • 24,624
  • 7
  • 58
  • 106
16
votes
4 answers

Rails 3.1 with Asset Pipeline, link_to :confirm message showing twice?

Okay, so I've seen this question about this problem being caused by multiple linkings of jQuery or Prototype, but I can confirm that I'm only linking to jQuery once on the entire page. My problem is this: when I have a link_to that confirms a…
16
votes
3 answers

How do I get escape_javascript and other helpers in my sprockets pre-processed js file (not a view)?

I'm using Rails 3.1 and the sprockets stuff. I want to use ERB to pre-process a js file that will then be included using javascript_include_tag. It is generated from code, and so I'm pre-processing it with ERB, but I can't get to the helpers like…
nocache
  • 1,805
  • 16
  • 18
16
votes
2 answers

How assets precompile in development environment on ruby on rails?

Why can't we precompile assets in a development environment? I know that sprockets basically compile all assets. When we go in production environment then we run the command: rake assets:precompile But in the development env we can't do anything…
user5326892
15
votes
2 answers

Sprockets encoding error on js file: invalid UTF-8 byte sequence

A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8. The line in question is: * Copyright (c) 2010 - 2011 Johan Säll Larsson If I replace the ä character, the problem goes away, but I don't want…
weston
  • 1,972
  • 17
  • 17
15
votes
3 answers

Assets say "not precompiled" when they are precompiled

Ok so, I'm getting this error when I try to use the asset pipeline. I don't understand what's causing it. Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#show Showing .../app/views/photos/_photo_view.html.haml where…
Andrew
  • 42,517
  • 51
  • 181
  • 281
1 2
3
53 54