Error Compiling Asset Application.js
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up application.js isn't precompiled up vote 0 down vote favorite I'm not sure why, but whenever I run rake assets:precompile, application.js doesn't get compiled. I get a "application.js isn't precompiled" error in production mode. Here is my Gemfile if it means anything: source 'http://rubygems.org' gem 'rails', '3.1.1' gem 'eventmachine', '1.0.0.beta.4.1' gem 'thin' gem 'mysql' gem 'win32-open3-19' gem 'paperclip', '2.3.8' #gem 'jammit' gem 'jsmin' gem 'will_paginate' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' # Gems used only for assets and not required # in production environments by default. group :assets do gem 'sass-rails', '~> 3.1.4' gem 'coffee-rails', '~> 3.1.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' # Use unicorn as the web server # gem 'unicorn' # Deploy with Capistrano # gem 'capistrano' # To use debugger # gem 'ruby-debug19', :require => 'ruby-debug' group :test do # Pretty printed test output gem 'turn', :require => false end I made a new rails app and tested the rake assets:precompile and it's working. The only difference between the two apps in terms of relevant files would be what gems I have installed. "application.js" is the same between both apps...as are the environment.rb files. 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 obviously fail with 404. However the application.js file is referenced correctly. UPDATE: Looking into what Sprockets generates I've noticed that the "logical path" uses "../javascripts" in the location. I tes
Sign in Pricing Blog Support Search GitHub This repository Watch 1,512 Star 24,215 Fork 5,314 zurb/foundation-sites Code Issues 466 Pull requests 53 Projects 0 Wiki Pulse Graphs New issue Possible issue with precompiling assets (specifically, modernizr) #3672 Closed JamesChevalier opened this Issue Nov 24, 2013 · 11 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 10 participants JamesChevalier commented Nov 24, 2013 I'm getting this error in production: Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: vendor/modernizr.js isn't precompiled My application.html.erb file contains: <%= javascript_include_tag '//www.google.com/jsapi', 'chartkick', 'https://js.stripe.com/v1/', 'vendor/modernizr' %> My http://stackoverflow.com/questions/8470025/application-js-isnt-precompiled application.js file is: //= require jquery //= require jquery_ujs //= require foundation //= require_tree . $(function(){ $(document).foundation(); }); I ran RAILS_ENV=production bundle exec rake assets:precompile on the server, but that didn't resolve the issue (it did run without error). I'm using capistrano to deploy my application, but I don't see any configuration settings that seem relevant to this issue. I've got another Rails application, https://github.com/zurb/foundation-sites/issues/3672 running Foundation 4, on the same server. That application does have a shared/assets/vendor/custom.modernizr.js file. I'm not sure what I'm doing wrong, or what I've missed. JamesChevalier commented Nov 24, 2013 As a temporary workaround, I've manually placed the modernizr.js file in the public folder and I've changed my application.html.erb file to: <%= javascript_include_tag '//www.google.com/jsapi', 'chartkick', 'https://js.stripe.com/v1/' %> shaneog commented Nov 26, 2013 Here is how I've fixed this. It seems to be a Rails 4/Sprockets issue (and thus this is a Foundation 5 docs issue). Copy the modernizr.js file from the foundation-rails gem into your vendor/assets/javascripts directory. Then in your production.rb file you need to add this line (or edit it to add modernizr.js) config.assets.precompile += %w( modernizr.js ) Now, in your application.html.rb file you need to edit the line <%= javascript_include_tag "vendor/modernizr" %> to read <%= javascript_include_tag "modernizr" %> xanview commented Dec 12, 2013 Thank you for the workaround but Is there a better solution for this that doesn't involve manually copying code from the foundation-rails gem? btsai commented Dec 15, 2013 looks like the foundation 5 docs are incomplete. this seems to do the trick: in config/environm
Rails Asset Pipeline By Mikel Lindsaar, 22 October 2013 twitter Scroll down to read Face it, you are a top developer, one of the best at your game, you eat https://www.reinteractive.net/posts/116-12-tips-for-the-rails-asset-pipeline lambda's for breakfast, refactor whole apps as an afternoon snack and bad https://launchschool.com/blog/rails-asset-pipeline-best-practices code just trembles when you approach. You are at the top of your game and nothing stands in between you and the code you desire. Yet, the Rails asset pipeline still trips you up, not once, not twice, but just about every time you try and use it. Here's a list error compiling of things that I have learnt that aren't necessarily obvious, that can help you tame this wild and savage beast. 1. Two options, precompile OR include, not both No CSS or JS files will be available to your app through the asset pipeline unless they are included in other files OR listed in the config.precompile directive (see #2 and #3 below). Only application.css and error compiling asset application.js are available by default of all the CSS and JS files. For example, you make a file in the assets folder called: app/assets/stylesheets/site.css.scss And you want to include this in your page. You have two options, either include it as one of the CSS files to be loaded up in application.css with the following: // = require_self // = require 'site' And then it will be inside the compiled public/assets/application.css which is included with: stylesheet_link_tag "application" OR you can add it to the precompile list like so: config.assets.precompile += %w( site.css ) and then reference it with: stylesheet_link_tag "site" The reason this happens is that when you run rake assets:precompile Rails looks through your assets folder and copies over everything that is not Javascript or CSS into public/assets. It then creates application.js by reading app\assets\javascripts\application.js, and application.css by reading app\assets\stylesheets\application.css, loading up all the "require" files it finds in there, and does not look at any other file unless you explicitly tell it to. 2. File extensions matter in the precompile directive Another common mistake is forgetting to put the file extension on the precompile directive, for example: config.ass
tools and mechanisms by which Javascript files, stylesheets, and images are processed and prepared for use by the browser. These processes can minify and compress assets, as well as pre-process assets that are written in other languages such as Coffeescript or Sass. The asset pipeline was created to solve a variety of problems related to static assets. One such issue is that each asset specified separately in the HTML markup must be retrieved separately, resulting in a higher number of HTTP requests and, in the end, a longer load time. Raw Javascript and CSS files can also waste a lot of bandwidth with comments, extra white space, and long variable names. Another issue that comes up involves caching. When you serve up a Javascript file from your server, for example, the browser will automatically cache that file for a period of time. That improves page load time, but what if that asset changes at a later point in time? The browser won’t know about it, so it will continue to use the cached asset until its cache life has expired. Finally, languages such as Coffeescript, Sass, Less, and Erb have made it easier to organize and write Javascript and CSS, but the browser can’t interpret them directly, so a pre-processor is needed to convert those files into their appropriate counterparts before they are sent off to the browser. The asset pipeline, in its benevolence, can solve all of the above problems when used properly. It can compile multiple assets into one, minify and compress assets, provide digesting of assets to avoid caching issues, and can pre-process alternative languages and turn them into Javascript and CSS. This post covers a variety of topics related to the asset pipeline: the basics of how to use the asset pipeline best practices for structuring where to put your assets how to use the precompile array to specify what files are processed by the asset pipeline how Sass and Coffeescript can be leveraged how to use Rails asset helper methods, and some gotchas Basic Usage There are two basic ways that the asset pipeline is used: When running a server in development mode, it automatically pre-processes and prepares your assets on-the-fly. In production mode, you’ll probably use it to pre-process, versionize, and compress and compile your assets. You can do so by running the following command: 1 bundle exec rake assets:precompile This will