【发布时间】:2014-10-23 02:46:29
【问题描述】:
这可能以前被问过。我已经用一些解决方案搜索了堆栈溢出。我试图实现那些很少:)。我被困住了。请帮忙。我是 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
请帮助编译。有什么想法吗?
【问题讨论】:
-
您需要在项目文件夹上运行
rake assets:precompile,您可以在本地或远程服务器中执行此操作,但在远程服务器中才是真正应该执行的地方,这是您的问题吗? -
我已经运行了.. 对我没有用
-
你怎么知道的?你检查你的
public/assets文件夹了吗?当说它不起作用时,请尝试更具体。 -
是的,在公共资产文件夹中有两个空文件 application.css 和 application.js...
-
然后它之前工作过,为了它重新生成文件,我通常使用
rm -rf public/assets && rake assets:precompile
标签: css ruby-on-rails ruby asset-pipeline