Home > Rails Error > Rails Error Compiling Asset Application.js

Rails Error Compiling Asset Application.js

Also, creating an application with the --skip-sprockets option will generate a slightly different config/application.rb file, with a require statement for the sprockets railtie that is commented-out. This means anything that compiles to JS/CSS is excluded, as well as raw JS/CSS files; for example, .coffee and .scss files are not automatically included as they compile to JS/CSS.If you If you are upgrading from Rails 3, please take into account that assets under lib/assets or vendor/assets are available for inclusion via the application manifests but no longer part of the In Rails 4.x this option has been removed and is no longer needed. Check This Out

The files will be copied to their correct locations after they are generated. The above, with a require_self can be written in a .js file as follows: 1 2 3 4 5 6 7 // In application.js //

If you have a folder of files that you want to include, you’ll have to add that to the manifest as well: 1 #= require_tree ./components One more Draw an hourglass Jokes about Monica's haircut SSH makes all typed passwords visible when command is provided as an argument to the SSH command Does the local network need to be For one, nothing in the public folder will get pre-processed, compiled, or compressed automatically, so by putting assets there, you are completely bypassing the asset pipeline and losing all of its Note that require_tree does not compile assets recursively through directories.

Here is the gemfile: gem 'rails', '3.1.1.rc1' gem 'pg' gem 'sass-rails', " ~> 3.1.0" group :assets do gem 'therubyracer' # gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier', This is unexpected and a pain in the ass. They contain information about which files are to be used by your app. You can disable it while creating a new application by passing the --skip-sprockets option.

latortuga commented Sep 6, 2012 @jpmckinney I updated one of my previous comments to be more explicit on this note but I reviewed my other replies and the wiki page and Debugging One of the best tools to debug your generated assets is to view them on your dynos: $ heroku run bash $ ls public/assets You should see a manifest-.json or Finding a missing sequential number in a data file How to make sure that my operating system is not affected by CVE-2016-5195 (Dirty COW)? I’ve precompiled, but styles still don’tload If you’ve precompiled, double-check that compilation actually worked by listing the contents of the public/assets directory of your application on the productionserver: ls -l public/assets

Query strings in particular do not work at all with some CDNs for cache invalidation. The problem lies in the foundation-rails gem. I've tried every suggestion in this thread but it still refuses to work. I'm not sure what I'm doing wrong, or what I've missed.

Since the assets from a CDN are geographically closer to the browser, the request is faster, and since your server doesn't need to spend time serving assets, it can focus on latortuga commented Sep 6, 2012 @jpmckinney why would Heroku care what the precompile list includes if it's not precompiling? Yes there are other options for compiling assets, including precompiling locally and live compilation. To include a CSS or Javascript file other than application.css and application.js, you have to require it in one of two ways: Add it to the precompile array in config/initializers/assets.rb (Rails

How to package assets with a gem. his comment is here Everything is working fine in dev, just not in production. –JakeTheSnake Dec 12 '11 at 5:14 have you changes the precompile config option from the default? –Richard Hulse Dec Already have an account? Also found this on SO which says you should precompile before deploy and it works fine.

config/application.rb), or Include the file in your asset’s manifest or one of its sub-file’s manifest. Instead, setting config.assets.css_compressor and config.assets.js_compressor will control compression of CSS and JavaScript assets.5.3 Serving GZipped version of assetsBy default, gzipped version of compiled assets will be generated, along with the non-gzipped config.assets.precompile += %w[ active_admin.css active_admin.js ] in application.rb. this contact form This is very helpful for assets that are not modified so that a browser does not need to re-download a website's CSS or JavaScript on every request.

Here's a list of things that I have learnt that aren't necessarily obvious, that can help you tame this wild and savage beast. 1. The file name can change between nodes in multi-server environments. These should be used in the order the processing should be applied.

config.assets.css_compressor = :yui The other option for compressing CSS if you have the sass-rails gem installed is config.assets.css_compressor = :sass 5.2 JavaScript CompressionPossible options for JavaScript compression are :closure, :uglifier and

Known issues There are two known issues with Rails 4 (sprockets) that can be difficult to detect or debug. If you already use this shared folder you'll need to write your own deployment task.It is important that this folder is shared between deployments so that remotely cached pages referencing the gem 'sass-rails', "~> 3.1.0" # had to take this line out of group :assets for some reason I forget.. A typical manifest file looks like: {"files":{"application-723d1be6cc741a3aabb1cec24276d681.js":{"logical_path":"application.js","mtime":"2013-07-26T22:55:03-07:00","size":302506, "digest":"723d1be6cc741a3aabb1cec24276d681"},"application-12b3c7dd74d2e9df37e7cbb1efa76a6d.css":{"logical_path":"application.css","mtime":"2013-07-26T22:54:54-07:00","size":1560, "digest":"12b3c7dd74d2e9df37e7cbb1efa76a6d"},"application-1c5752789588ac18d7e1a50b1f0fd4c2.css":{"logical_path":"application.css","mtime":"2013-07-26T22:56:17-07:00","size":1591, "digest":"1c5752789588ac18d7e1a50b1f0fd4c2"},"favicon-a9c641bf2b81f0476e876f7c5e375969.ico":{"logical_path":"favicon.ico","mtime":"2013-07-26T23:00:10-07:00","size":1406, "digest":"a9c641bf2b81f0476e876f7c5e375969"},"my_image-231a680f23887d9dd70710ea5efd3c62.png":{"logical_path":"my_image.png","mtime":"2013-07-26T23:00:27-07:00","size":6646, "digest":"231a680f23887d9dd70710ea5efd3c62"}},"assets":{"application.js": "application-723d1be6cc741a3aabb1cec24276d681.js","application.css": "application-1c5752789588ac18d7e1a50b1f0fd4c2.css", "favicon.ico":"favicona9c641bf2b81f0476e876f7c5e375969.ico","my_image.png": "my_image-231a680f23887d9dd70710ea5efd3c62.png"}} The default location for the manifest is the root of the location specified in config.assets.prefix

jschwindt commented Dec 7, 2011 @abuisman Yes, it works, but that way the assets are compiled after the first request and it can take time. I'm trying to deploy to Heroku Cedar and getting the same error. Also of note...when I include a random .js file in my assets/javascripts directory and use "javascript_include_tag :application", one of the resulting URLs in dev mode look like so: /assets/../javascripts/anytimec.js?body=1 and they navigate here group :assets do gem 'sass-rails', " ~> 3.1.0" gem 'coffee-rails', "~> 3.1.0" gem 'uglifier' end gem 'jquery-rails' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano

To precompile locally, you need to do the following: Setup a dummy production database on your local machine Create a production entry in database.yml Add in any other dummy settings to You can choose from a set of built in options or specify your own.The third feature of the asset pipeline is it allows coding assets via a higher-level language, with precompilation If all else fails, manually clear out the tmp and public/assetsdirectories: rm -rf tmp/* rm -rf public/assets/* Then retry your deploymentsteps. via thin or webrick on port 3000), assets will notwork.

lib/assets is for your own libraries' code that doesn't really fit into the scope of the application or those libraries which are shared across applications. The browser won’t know about it, so it will continue to use the cached asset until its cache life has expired. jQuery, backbone.js, etc.) should be placed in the vendor/assets/ directory: 1 2 3 4 5 6 7 8 9 10 11 rails-app/ app/ assets/ config.action_controller.asset_host = 'mycdn.fictional-cdn.com').

If you’re going to write plain-old Javascript and CSS, you should definitely be using a linter. kbighorse commented Apr 12, 2012 Heroku user, neither production.rb nor application.rb are working for me, any solutions? Precompilation You may now be wondering if everything you put in the app/assets/javascripts/ folder will be automatically precompiled for your app. It seems to be a Rails 4/Sprockets issue (and thus this is a Foundation 5 docs issue).

How can I get my Rails 3 assets to compile faster? The same applies to a JavaScript file - app/assets/javascripts/projects.coffee.erb is processed as ERB, then CoffeeScript, and served as JavaScript.Keep in mind the order of these preprocessors is important. So I am not sure of the consequences latortuga commented Sep 4, 2012 @GideonJa I noted in the wiki that you cannot use production.rb on Heroku, it is ignored during precompile. What if I have 40 css files? –yozzz May 27 '14 at 8:48 add a comment| up vote 9 down vote For all those who are reading this but do not

You can enable or disable it in your configuration through the config.assets.digest option.More reading: Optimize caching Revving Filenames: don't use querystring 2 How to Use the Asset PipelineIn previous versions of This could lead to unexpected inconsistency if a slug was compiled with a different set of config vars than those it is run against. Without this change, the application would serve the precompiled assets from /assets in development, and you would not see any local changes until you compile assets again.In practice, this will allow