Rails 请教关于 assets pipeline 的一个问题

anklos · 2012年07月19日 · 2306 次阅读

在给公司做个 gem,目的是自动生成一些可配置的 theme 模版。这样在很多小型网站开发种能重复调用,然后做一些不同的 config 来生成不同的页面。对 asset pipeline 不是很不熟悉,只有硬着头皮来。。

现在生成模版大概的结构是:

app/
themes/ theme1/ images/ javascripts/ stylesheets/ theme1.css theme1.css.erb views/ demo.html.erb theme2/ … theme3/ …

在 controller 里,我可以这样:

class MyAppController < ApplicationController

theme 'theme1' #挑选 theme1

config_theme {:ulr => 'test', :background => :img…}

def demo render 'demo' #从 theme1 里拿到 demo 的页面 end end

遇到的问题是我无法调用到 theme1 下 stylesheets 里的 css。有几点:

  1. prepend_view_path 无法让 css 在设定的路径下搜寻。
  2. 即使我给绝对路径,仍然无法拿到 css。(我已经设置了config.assets.paths << "#{Rails.root}/app/themes" ), 因为 app/themes/不是 public?
  3. 根据不同 controller 里配出来的 theme1.css.erb 是无法 precompile 的吧?那这种情况应该如何压缩或者其他优化方法?

谢谢!

暂无回复。
需要 登录 后方可回复, 如果你还没有账号请 注册新账号