Rails 4 assets.precompile

Art*_*ves 12 ruby-on-rails asset-pipeline

这是一个常见的问题,但没有一个解决方案解决了我的问题,所以在这里:

我将ace.js添加到我的rails4应用程序中,所以我做的是

- 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")
Run Code Online (Sandbox Code Playgroud)

所以在我的布局文件中我有:

<%= javascript_include_tag "ace" %>
Run Code Online (Sandbox Code Playgroud)

它在dev上运行得很好,但是当我运行时:

RAILS_ENV=production bundle exec rake assets:precompile
Run Code Online (Sandbox Code Playgroud)

它不会创建ace文件的摘要版本.

我错过了什么吗?

小智 22

通过添加以下内容解决:

config.assets.precompile += %w( index.js )
Run Code Online (Sandbox Code Playgroud)

config/application.rb.(不是config/environments/production.rb)

在Rails 4.0 beta1中测试过.

  • 谢谢这真的帮助了我.这是Rails 4的变化吗?用户在`production.rb`但是文档不明确指出现在应该在`application.rb'中设置 (4认同)