2011-11-23 126 views
0

我已经在我的资产应用程序的文件夹结构如下:在我application.haml.html资产管道导轨3结构

- app 
    - assets 
    - application.scss 
    - themes 
     - mytheme 
     - default.scss 

而且我做的:

= stylesheet_link_tag 'application' 
= stylesheet_link_tag "themes/mytheme/default" 

现在,当我预编译我的资产,application.css位于我的public/assets文件夹中,但mytheme的default.css不存在。这让我总是在临时环境的错误:

::的ActionView ::模板错误(主题/ mytheme的/ default.css不 预编译)

什么我不得不这样做编译器正在将我所有的资产编译?

回答

1

尝试修改您的配置文件中是这样的:

config.assets.precompile + = [ 'default.css']

,然后运行耙预编译任务。您可能需要包含资产的完整路径。您可以找到有关asset pipeline hereinformation about compiling assets here的具体信息。

+0

谢谢。不知道他只是在检查application.js和application.css – SteenhouwerD

0

有几种方法来避免异常:
首先是:
不要在布局或视图使用= stylesheet_link_tag "themes/mytheme/default"。只需在application.css文件中添加适当的说明(我的意思是require语句)。
第二个:
您可以打开application.rb文件中的'live asset compilation'。

第三:
您可以添加“themes/mytheme/default”编译链轮路径。 下面是更多的资源为:Asset pipeline

1

您也可以为每个主题设置不同的布局。虽然它不是非常干燥,但为了减少负面变化的影响,应用程序模块可以分离一些代码。类似于Fragile base class问题的东西。

我会利用index manifest并将您的app/assets组织成分离模块。以下结构属于我目前正在开发的一个项目。 比方说,你的应用程序组成了三个模块组成:公共端,管理员UI和,例如CRM让你的代理跟踪销售过程,在您的公司:

app/assets/ 
├── coffeescripts 
│   ├── admin 
│   │   ├── components 
│   │   ├── index.coffee 
│   │   └── initializers 
│   ├── application 
│   │   ├── components 
│   │   ├── index.sass 
│   │   └── initializers 
│   └── crm 
│    ├── components 
│    ├── index.sass 
│    └── initializers 
├── images 
│   ├── admin 
│   ├── application 
│   └── crm 
└── stylesheets 
    ├── admin 
    │   ├── components 
    │   └── index.sass 
    ├── application 
    │   ├── components 
    │   └── index.sass 
    └── crm 
     ├── components 
     └── index.sass 

21 directories, 6 files 

你可以让每一个模块主题,可能还有core_theme包含常见的样式表,图像和最终的JS组件。

要么你选择一个单一的共享布局,你可以添加下面的代码将会引导你进入更有序的代码库和正确的预编译生产资源。

= stylesheet_link_tag 'theme_a' 
= javascript_include_tag 'theme_a' 

不要忘记更新您的application.rb所以他们将被正确预编译:

config.assets.precompile = %w(admin.js application.js crm.js 
           admin.css application.css crm.css)