我根据 rails 的入门教程,写了个简单的 blog,想要部署到 openshift 上,发现 application.css(该 application.css 是 rails 自动创建的) 无法在 production 环境下(准确的说是 openshift 下)生成。
具体情况是这样的: 在 app/assets 下,我有几个文件:
stylesheets/
├── application.css
├── comments.css.scss
├── home.css.scss
├── messages.css.scss
├── pages.css.scss
├── posts.css.scss
└── scaffolds.css.scss
其中,application.css 的内容如下:
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* 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 .
*/
如果我在本地执行
rake assets:precompile
那么可以在 public/assets 目录下找到生成的 css 文件 (在 production 环境下),在本地启动 rails 服务,浏览器访问显示 css 工作正常。
但是,上传到 openshift 后,在浏览器里访问,发现/assets/application.css 的内容为空,而我尝试访问 /assets/home.css 却可以看到有内容。因此,这里可以确认:
在 app/assets/stylesheets 下的 home.scss 已经被正确生成
那么,与 home.scss 同在一个目录下的 application.css 为什么没有被正确生成涅?home.scss 的后缀是 .scss, application.css 的后缀是 css
另外,在 app/assets/javascripts/下的 application.js 却可以正常生成(通过浏览器访问可以看到里面的内容)
openshift 上传时,显示 已经 进行了 rake assets:precompile,
...
remote: Using uglifier (1.3.0)
remote: Using will_paginate (3.0.4)
remote: Your bundle is complete! It was installed into ./vendor/bundle
remote: Precompiling with 'bundle exec rake assets:precompile'
remote: [RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
remote: Running .openshift/action_hooks/build
remote: Running .openshift/action_hooks/deploy
remote: Database server found at 127.3.139.1. initializing...
remote: The method 'YAML.enable_arbitrary_object_deserialization!' is deprecated and will be removed in the next release of SafeYAML -- set the SafeYAML::OPTIONS[:default_mode] to either :safe or :unsafe.
remote: [RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
remote: hot_deploy_added=false
remote: MySQL already running
remote: Done
remote: Running .openshift/action_hooks/post_deploy
各位,有遇到过这样的问题不?或者有什么建议?非常欢迎。