Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 4 assets.precompile

This is a common question in here, but none of the solutions fixed my problem, so here it goes:

I am adding ace.js to my rails4 app, So what I did was

- Added vendor/assets/ace/ace.js
- Created vendor/assets/ace/index.js , with content
  //= require ace  
- Added the following to my production.rb
  config.assets.precompile += %w( index.js )  
  config.assets.paths << Rails.root.join("vendor", "assets", "ace")

So in my layout file I have:

<%= javascript_include_tag "ace" %>

and it works just fine on dev, but when I run:

RAILS_ENV=production bundle exec rake assets:precompile

It doest not create the digest version of the ace file.

Am I missing something?

like image 899
Arthur Neves Avatar asked Feb 14 '13 19:02

Arthur Neves


People also ask

How do you Precompile rails assets?

To compile your assets locally, run the assets:precompile task locally on your app. Make sure to use the production environment so that the production version of your assets are generated. A public/assets directory will be created. Inside this directory you'll find a manifest.

What is assets Precompile?

rails assets:precompile is the task that does the compilation (concatenation, minification, and preprocessing). When the task is run, Rails first looks at the files in the config.assets.precompile array. By default, this array includes application.js and application.css .

What does rake assets Clean do?

rake assets:clean Only removes old assets (keeps the most recent 3 copies) from public/assets . Useful when doing rolling deploys that may still be serving old assets while the new ones are being compiled.


1 Answers

It is solved by adding :

config.assets.precompile += %w( index.js )

to config/application.rb. (not config/environments/production.rb)

Tested in Rails 4.0 beta1.

like image 130
ccq1170 Avatar answered Oct 01 '22 17:10

ccq1170