【发布时间】:2012-01-19 07:59:26
【问题描述】:
所以我开始构建一个 gem,这很困难,但到目前为止它似乎正在奏效..
除了一件小事,资产。我尝试将它们放入我的lib/assets、app/assets 和vendor/assets。但它们似乎没有加载。
我有一个测试应用程序,它加载我的 gem 来测试它,但似乎没有任何效果。我的 gem 中有一个引擎,我确定它正在加载。
我还需要知道什么才能开始工作?
编辑:
这是我的引擎(位于lib/baco/engine.rb):
require 'rails'
module Baco
class Engine < Rails::Engine
end
end
编辑 2:
这是我的 css 文件(位于vendor/assets/stylesheets/application.css.scss):
/*
* 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 baco
*/
input {
padding:10px;
}
【问题讨论】:
-
老鼠,我希望这就是问题所在。您在 Gem 的根目录下有 vendor 文件夹(不在 lib 中)?您如何引用 Gem 中的资产?
-
是的,我有一个名为
application.css.scss的文件,位于vendor/assets/stylesheets -
有什么好的调试方法吗?例如跟踪资产管道使用的所有路径..?
-
您可以通过启动 Rails 控制台并执行
Rails.application.config.assets.paths来检查资产路径。
标签: ruby-on-rails gem asset-pipeline rails-engines