【问题标题】:Developing rails engines and using the asset pipeline开发 Rails 引擎并使用资产管道
【发布时间】:2012-01-19 07:59:26
【问题描述】:

所以我开始构建一个 gem,这很困难,但到目前为止它似乎正在奏效.. 除了一件小事,资产。我尝试将它们放入我的lib/assetsapp/assetsvendor/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


【解决方案1】:

原来我仍然需要加载 gem 的应用程序中的 css..

这是正常情况吗?因为我还没有在任何地方读到过这方面的内容..

无论如何,让它工作,感谢你的研究,希望这个话题可以帮助其他人..

【讨论】:

  • 是的,这是正常行为。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多