之前可能已经提出过这个问题。我已经通过堆栈溢出搜索了一些解决方案。我尝试用小:)实现那些。我被卡住了。请帮忙。我是rails的新手
我在assts文件夹中有几个scss文件,如下所示
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
请帮助我们编译。有什么想法吗?
答案 0 :(得分:1)
您必须在资产预编译之前设置RAILS_ENV值,因为默认情况下RAILS_ENV等于' development',但您需要设置' production'。试试这个:
RAILS_ENV=production bundle exec rake assets:precompile