作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 Ruby 和 Rails 的新手,我已经考虑了好几天了,还没有找到解决方案。我的项目在我的开发环境中运行良好,但在我的 alpha 或生产环境中却不行。
我的 app/assets/stylesheets 文件夹中有以下样式表:
app
--> assets
--> stylesheets
--> modules
--> _header.css.scss
--> _footer.css.scss
--> home.css.scss
--> user.css.scss
--> help.css.scss
rails s --environment=alpha
)时,我收到此错误:
Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Home#index
Showing /app/views/home/index.haml where line #1 raised:
home.css isn't precompiled
stylesheet_link_tag('home')
将该样式表添加到我的 View 中.
alpha.rb
文件有这个:
config.assets.compile = false
config.assets.precompile += %w( help.css home.css users.css )
config.assets.compress = true
config.assets.debug = false
rake assets:precompile RAILS_ENV=alpha
)。该任务似乎工作正常。这是输出:
rake assets:precompile RAILS_ENV=alpha --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/ruby-1.9.3-p286/bin/rake assets:precompile:all RAILS_ENV=alpha RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Invoke rails_admin:disable_initializer (first_time)
** Execute rails_admin:disable_initializer
[RailsAdmin] RailsAdmin initialization disabled by default. Pass SKIP_RAILS_ADMIN_INITIALIZER=false if you need it.
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
/public/assets/
中结束,以及
/public/assets/manifest.yml
正在创建并列出了我的文件:
application.css: application.css
help.css: help.css
home.css: home.css
users.css: users.css
http://localhost:3000
),我会得到前面提到的
AssetNotPrecompiledError
home.css
的错误;但是,
http://localhost:3000/assets/home.css
确实返回样式表。
home.css
的位置位于;但是,它在
manifest.yml
上列出,我认为它应该在哪里寻找它。
@import 'modules/header';
@import 'modules/footer';
body {
background: $bgColor asset-url('bgFull.jpg', image) repeat-x center top;
}
div.main {
padding: 35px 30px;
background: $whitweColor;
margin-top: -3px;
padding-bottom: 30px;
@include border-bottom-left-radius(5px);
@include border-bottom-right-radius(5px);
h1 {
font-size: 2em;
}
h2 {
font-size: 1.5em;
}
}
@media only screen and (max-width: 767px) {
body {
background: $bgColor asset-url('bg.png', image) repeat-x;
}
}
最佳答案
我建议您坚持有关 list 文件的默认设置。它们是 Assets 管道的管理点。在您的情况下,有几件事要做:
css
来自 application.css
的定义到 app/assets/stylesheets
中的单独 css 文件*= require_self
*= require jquery
*= require jquery_ujs
*= require_tree .
assets/stylesheets
对于新目录,就像您正在尝试做的那样,最好在 application.rb
中提及这一点像这样 :config.assets.paths << Rails.root.join("app", "assets", "styleshhets", "modules")
public/assets
在开发环境中。它使事情变得无用复杂。就靠
app/assets
.
关于ruby-on-rails - Rails AssetNotPrecompiledError 即使 Assets 正在预编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14322356/
我是 Ruby 和 Rails 的新手,我已经考虑了好几天了,还没有找到解决方案。我的项目在我的开发环境中运行良好,但在我的 alpha 或生产环境中却不行。 我的 app/assets/styles
我有一张名为 pt_homepage_banner1.png 的图片。 我在生产环境中运行任务 bundle exec rake assets:precompile 它成功地将图像文件放入 publi
我有 html5-rails和 compass-html5在 Rails 3.1 上进行开发工作,但是当我在生产模式下运行我的应用程序并尝试访问我的主页时,我得到以下信息: Sprockets::He
我有一个使用引擎的应用程序(包含在 Gemfile gem my_engine, path=> '../my_engine' 中)。它适用于 rails 服务器 .我决定将它与乘客一起移至 nginx
我是一名优秀的程序员,十分优秀!