2

我运行 Rails 3.2 应用程序

我想让“twitter-bootstrap”只对后端用户可用。

在这个特定的后端布局中,我称之为后端样式表:

  <%= stylesheet_link_tag "backends" %>

我的资产结构如下所示:

stylesheets
   application.css.scss
   backends.css.scss
   partials
      _colors.css.scss

应用程序.css.scss

@import "compass/reset";
@import "compass/layout";
@import "compass/css3";
@import "compass/utilities";

// Font Settings

@import "partials/fonts";
@import "partials/colors";
@import "partials/pagination";

后端.css.scss

@import "bootstrap";
@import "partials/_colors.css.scss";

#fullscreen-green {
  background: $green;
  height: 100%;
  margin: 0;
}

我的 GEMFILE 资产包含以下内容:

group :assets do
  gem 'therubyracer', :platform => :ruby
  gem 'coffee-rails'
  gem 'sass-rails'
  gem "compass-rails"
  gem 'bootstrap-sass'
  gem 'uglifier'
end

一切都在 localhost 的开发中完美运行。但是当我推送到 heroku cedar 堆栈并调用后端(生产)时,应用程序崩溃了:

2013-04-07T17:56:26+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2013-04-07T17:56:26+00:00 app[web.1]: Load path: /app
2013-04-07T17:56:26+00:00 app[web.1]:   (in /app/app/assets/stylesheets/backends.css.scss)):
2013-04-07T17:56:26+00:00 app[web.1]:     4:
2013-04-07T17:56:26+00:00 app[web.1]:     5: <head>
2013-04-07T17:56:26+00:00 app[web.1]:     6:   <title><%= content_for?(:title) ? yield(:title) : "title" %></title>
2013-04-07T17:56:26+00:00 app[web.1]:     7:   <%= stylesheet_link_tag "backends" %>
2013-04-07T17:56:26+00:00 app[web.1]:     8:   <%= stylesheet_link_tag "application" %>
2013-04-07T17:56:26+00:00 app[web.1]:     9:   <%= csrf_meta_tag %>
2013-04-07T17:56:26+00:00 app[web.1]:     10:   <%= javascript_include_tag "application" %>
2013-04-07T17:56:26+00:00 app[web.1]:   app/assets/stylesheets/backends.css.scss:2
2013-04-07T17:56:26+00:00 app[web.1]:   app/views/layouts/backend.html.erb:7:in `_app_views_layouts_backend_html_erb__3568065575647724370_33921820'
2013-04-07T17:56:26+00:00 app[web.1]:   app/controllers/dashboards_controller.rb:8:in `index'

配置/生产.rb

config.assets.compile = true
config.assets.compress = true
config.assets.precompile += Ckeditor.assets

请记住,我只想在特定布局中使用引导程序,而不是在应用程序范围内。

heroku也运行 rake assets:precompile

有人可以帮我吗!?从整个星期天开始尝试解决这个 *$/%&§

提前致谢!

4

1 回答 1

3

我通过在资产块之外放置三个宝石解决了这个问题:

group :assets do
  gem 'therubyracer', :platform => :ruby
  gem 'coffee-rails'
  gem 'uglifier'
end

gem 'sass-rails'
gem "compass-rails"
gem 'bootstrap-sass'
于 2013-04-08T11:08:32.083 回答