【问题标题】:Bootstrap with Spree works locally but not on Heroku带有 Spree 的 Bootstrap 可以在本地工作,但不能在 Heroku 上工作
【发布时间】:2013-04-19 16:27:46
【问题描述】:

我正在使用 Ruby On Rails、Bootstrap 和 Spree 创建一个应用程序。我的本地主机上一切正常,但是当我推送到 Heroku 时,我收到一条错误消息“我们很抱歉,但出了点问题。”当我将“/store”添加到加载正常的地址时,我可以访问 Heroku 上的商店区域,但主页加载时显示错误消息。当我运行 heroku 日志时,我看到了这个:

Processing by PagesController#home as HTML
2013-04-19T16:03:19.156092+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (100.2ms)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled jquery.alerts/jquery.alerts.css  (145ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled jquery.alerts/jquery.alerts.spree.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled responsive-tables.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled normalize.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled skeleton.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled jquery-ui.datepicker.css  (259ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled jquery.powertip.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156092+00:00 app[web.1]: Compiled select2.css  (2728ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled admin/spree_admin.css  (1552ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled admin/spree_core.css  (4771ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled admin/spree_promo.css  (1ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled admin/all.css  (4785ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled pages.css  (0ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled store/screen.css  (600ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled store/spree_core.css  (609ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled store/spree_promo.css  (11ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Compiled store/all.css  (631ms)  (pid 2)
2013-04-19T16:03:19.156538+00:00 app[web.1]: Completed 500 Internal Server Error in 5726ms
2013-04-19T16:03:19.149366+00:00 app[web.1]: 
2013-04-19T16:03:19.149366+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2013-04-19T16:03:19.149366+00:00 app[web.1]: Load path: /app
2013-04-19T16:03:19.149366+00:00 app[web.1]:     2: <html>
2013-04-19T16:03:19.149366+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2013-04-19T16:03:19.149842+00:00 app[web.1]:     8: </head>
2013-04-19T16:03:19.149366+00:00 app[web.1]:     4:   <title>Sample App</title>
2013-04-19T16:03:19.149842+00:00 app[web.1]:   app/assets/stylesheets/styles.css.scss:5
2013-04-19T16:03:19.149842+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_2bef37236eb3fbbf2665a458326374e1'
2013-04-19T16:03:19.149366+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2013-04-19T16:03:19.149366+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2013-04-19T16:03:19.149366+00:00 app[web.1]:   (in /app/app/assets/stylesheets/styles.css.scss)):
2013-04-19T16:03:19.149366+00:00 app[web.1]:     3: <head>
2013-04-19T16:03:19.157636+00:00 heroku[router]: at=info method=GET path=/ host=guarded-headland-2911.herokuapp.com fwd="98.154.183.5" dyno=web.1 connect=6ms service=6092ms status=500 bytes=643
2013-04-19T16:03:27.655609+00:00 heroku[web.1]: Stopping remaining processes with SIGKILL
2013-04-19T16:03:27.655609+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM
2013-04-19T16:03:29.492003+00:00 heroku[web.1]: Process exited with status 137
2013-04-19T16:08:01.494500+00:00 app[web.1]: Started GET "/" for 98.154.183.5 at 2013-04-19 16:08:01 +0000
2013-04-19T16:08:01.526972+00:00 app[web.1]: 
2013-04-19T16:08:01.526972+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: bootstrap.
2013-04-19T16:08:01.526972+00:00 app[web.1]: Load path: /app
2013-04-19T16:08:01.526972+00:00 app[web.1]:   (in /app/app/assets/stylesheets/styles.css.scss)):
2013-04-19T16:08:01.526972+00:00 app[web.1]:     2: <html>
2013-04-19T16:08:01.526972+00:00 app[web.1]:     5:   <%= stylesheet_link_tag    "application", :media => "all" %>
2013-04-19T16:08:01.526972+00:00 app[web.1]:     7:   <%= csrf_meta_tags %>
2013-04-19T16:08:01.526972+00:00 app[web.1]:     6:   <%= javascript_include_tag "application" %>
2013-04-19T16:08:01.527299+00:00 app[web.1]: Completed 500 Internal Server Error in 20ms
2013-04-19T16:08:01.526972+00:00 app[web.1]:     3: <head>
2013-04-19T16:08:01.526972+00:00 app[web.1]:     4:   <title>Sample App</title>
2013-04-19T16:08:01.527299+00:00 app[web.1]: 
2013-04-19T16:08:01.527299+00:00 app[web.1]: 
2013-04-19T16:08:01.527299+00:00 app[web.1]:   app/assets/stylesheets/styles.css.scss:5
2013-04-19T16:08:01.527299+00:00 app[web.1]: Processing by PagesController#home as HTML
2013-04-19T16:08:01.527299+00:00 app[web.1]:     8: </head>
2013-04-19T16:08:01.527299+00:00 app[web.1]:   app/views/layouts/application.html.erb:5:in `_2be
f37236eb3fbbf2665a458326374e1'
2013-04-19T16:08:01.527299+00:00 app[web.1]:   Rendered pages/home.html.erb within layouts/application (0.2ms)
2013-04-19T16:08:01.536160+00:00 heroku[router]: at=info method=GET path=/ host=guarded-headland-2911.herokuapp.com fwd="98.154.183.5" dyno=web.1 connect=9ms service=82ms status=500 bytes=643

我的样式表 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 .
 */

gemfile 看起来像这样:

source 'https://rubygems.org'

gem 'rails', '3.2.13'
gem 'jquery-rails'
gem 'spree', '1.3.2'
gem 'spree_gateway', :github => 'spree/spree_gateway', :branch => '1-3-stable'
gem 'spree_auth_devise', :github => 'spree/spree_auth_devise', :branch => '1-3-stable'

group :production do
    gem 'pg'
end

group :development, :test do
    gem 'sqlite3'
end

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'bootstrap-sass', '~> 2.3.1'

end

【问题讨论】:

  • 您的 Gemfile 是什么样的?我怀疑这与您的 css 文件没有正确的文件类型名称有关。
  • 我发布了我的 gemfile。我对使用 Rails 很陌生,谢谢您的回复!如何正确命名 css 文件?再次感谢您的帮助。
  • 这个问题可能是徒劳的,但是在你的资产文件中,Spree 是否有机会创建任何 css 文件?
  • 是的。 assets/stylesheets/admin/all.css 和 assets/stylesheets/store/all.css
  • 为了好玩,将.scss文件添加到这两个文件的末尾,看看Heroku上会发生什么。虽然,我认为它不会起作用,因为您没有更改所有 css 文件。还将application.css 更改为application.css.scss

标签: ruby twitter-bootstrap heroku webpage spree


【解决方案1】:

如果我的 cmets 不起作用。那么我建议如下。

  1. application.css 更改为application.css.scss

  2. application.css.scss中删除*= require_tree .

  3. 将以下行@import "bootstrap";添加到文件application.css.scss的页面底部

唯一的问题是您将删除 Spree CSS 文件,因此 Spree 布局看起来不正确。目前 Spree 不提供对 Bootstrap 的官方支持。如果这不起作用,希望对 Spree 有更多了解的人可以帮助您。

【讨论】:

  • 我成功了!我做了你上面说的,我还在我的 application.rb 文件中添加了 config.assets.initialize_on_precompile = false 。谢谢你的帮助!!!
猜你喜欢
  • 2012-04-01
  • 2017-07-24
  • 1970-01-01
  • 1970-01-01
  • 2021-04-26
  • 1970-01-01
  • 2014-01-02
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多