这可能是以前问过的。我已经在堆栈溢出中搜索了一些解决方案。我试图用很少的实现:)。我被困住了。请帮忙。我是新手
我在asss文件夹中有几个scss fils,如下所示
assets
javascript
application.js
create.js.coffee
help.js.coffee
images
stylesheets
application.css
create.css.scss
forms.css.scss
help.css.scss
我需要的是在ruby资产管道中编译这些文件,使其编译然后合并,以便显示样式&&脚本,而这些未在我的网站上显示。
在application.js我有
// This is a manifest file that'll be compiled into including all the files listed below.
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
// be included in the compiled file accessible from http://example.com/assets/application.js
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
在application.css中,我有
/*
* This is a manifest file that'll automatically include all the stylesheets available in this directory
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
* the top of the compiled file, but it's generally better to create a new file per style scope.
*= require_self
*= require_tree .
*= require 'site'
*/
另外,在production.db中,我有
# Compress JavaScripts and CSS
config.assets.compress = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
请帮忙进行编译。有任何想法吗?
最佳答案
您必须在资产预编译之前设置RAILS_ENV值,因为默认情况下RAILS_ENV等于“开发”,但是您需要设置“生产”。尝试这个:RAILS_ENV=production bundle exec rake assets:precompile