找不到文件“twitter/bootstrap”生产中

发布于 2024-12-29 19:16:10 字数 1118 浏览 0 评论 0原文

我正在使用 Twitter 的 Bootstrap 翻译为 SCSS 文件。它可以在本地开发中工作,但是当我预编译并推送到 Heroku(使用 Cedar 堆栈)时,我得到:

> Started GET "/" for 74.57.16.130 at 2012-01-28 17:16:36 +0000 
> Processing by StaticPagesController#home as HTML  Rendered
> static_pages/home.html.erb within layouts/application (0.7ms) 
> Completed 500 Internal Server Error in 4ms
> 
>  ActionView::Template::Error (couldn't find file 'twitter/bootstrap'  
> (in /app/app/assets/stylesheets/application.scss.css:11)):
>      8: </head>
>      6:   <%= javascript_include_tag "application" %>
>      4:   <title><%= full_title(yield(:title)) %></title>
>      2: <html>
>      5:   <%= stylesheet_link_tag    "application", :media => "all" %>        
app/views/layouts/application.html.erb:5:in
> `_app_views_layouts_application_html_erb___288948710373692320_32137840'
>      3: <head>    cache: [GET /] miss
> 
>      7:   <%= csrf_meta_tags %>  cache: [GET /favicon.ico] miss

我使用的是 Rails 3.2.0,该应用程序一直在 Heroku 上运行,直到我添加 SASS 文件。

I'm using Twitter's Bootstrap translated to SCSS files. It works in local-development, but when I precompile and push to Heroku (using Cedar stack), I get this:

> Started GET "/" for 74.57.16.130 at 2012-01-28 17:16:36 +0000 
> Processing by StaticPagesController#home as HTML  Rendered
> static_pages/home.html.erb within layouts/application (0.7ms) 
> Completed 500 Internal Server Error in 4ms
> 
>  ActionView::Template::Error (couldn't find file 'twitter/bootstrap'  
> (in /app/app/assets/stylesheets/application.scss.css:11)):
>      8: </head>
>      6:   <%= javascript_include_tag "application" %>
>      4:   <title><%= full_title(yield(:title)) %></title>
>      2: <html>
>      5:   <%= stylesheet_link_tag    "application", :media => "all" %>        
app/views/layouts/application.html.erb:5:in
> `_app_views_layouts_application_html_erb___288948710373692320_32137840'
>      3: <head>    cache: [GET /] miss
> 
>      7:   <%= csrf_meta_tags %>  cache: [GET /favicon.ico] miss

I'm using Rails 3.2.0, the app was working on Heroku until I added the SASS files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

岁吢 2025-01-05 19:16:11

在 config/environments/production.rb 中添加以下行:

config.assets.precompile = [/^[-_a-zA-Z0-9]*\..*/]

我的猜测是它没有添加您的所有资产。

In config/environments/production.rb add this line:

config.assets.precompile = [/^[-_a-zA-Z0-9]*\..*/]

My guess is it is not adding all your assets.

飘落散花 2025-01-05 19:16:11

这解决了heroku中的问题至少

只是降级到sass-rails 3.1.4

group :assets do
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'sass-rails', '3.1.4'
  gem 'bootstrap-sass', '~> 2.0.2'
end

this solved the issue in heroku at least

just downgrade to sass-rails 3.1.4

group :assets do
  gem 'coffee-rails', '~> 3.1.1'
  gem 'uglifier', '>= 1.0.3'
  gem 'sass-rails', '3.1.4'
  gem 'bootstrap-sass', '~> 2.0.2'
end
伴我老 2025-01-05 19:16:11

当您将 Rails 应用程序部署到 heroku.com 时看到类似的内容时,

Precompiling assets failed, enabling runtime asset compilation
...
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port xxxx?

只需将其添加到 config/application.rb 中

config.assets.initialize_on_precompile = false

When you see something like this when you are deploying rails app to heroku.com

Precompiling assets failed, enabling runtime asset compilation
...
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port xxxx?

Just add this to config/application.rb

config.assets.initialize_on_precompile = false
独守阴晴ぅ圆缺 2025-01-05 19:16:11

确保在 config/environments/production.rb 中,您有...

config.serve_static_assets = true

Make sure, in config/environments/production.rb, you have...

config.serve_static_assets = true
假面具 2025-01-05 19:16:10

你用的是宝石吗?确保您的 gem 不属于资产组,并且可以在生产中访问。

来自 GemFile

# Gems used only for assets and not in production environments by default.

因此,只需将 gem 移到任何组之外就可以了。

Are you using a gem? Make sure your gem is not part of the assets group and is accessible in production.

From GemFile

# Gems used only for assets and not in production environments by default.

So just move the gem outside of any group and you should be okay.

神经暖 2025-01-05 19:16:10

只需将其放入您的 gemfile

gem "twitter-bootstrap-rails", "~> 2.0rc0"

BootStrap 2.0 中的 CSS 无效 会导致 SCSS 编译

失败可以通过查看输出来验证这一点,

git push heroku master 

您应该看到一些错误,例如:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Invalid CSS after "...er-radius:0 \0/": expected expression (e.g. 1px, bold), was ";}"
       (in /tmp/build_1k8ugei34dpcw/app/assets/stylesheets/application.css)

       Tasks: TOP => assets:precompile:primary
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

Just put this in your gemfile

gem "twitter-bootstrap-rails", "~> 2.0rc0"

There's invalid CSS in BootStrap 2.0 which causes SCSS compilation to fail

You can verify this by looking at the output of

git push heroku master 

You should see some error like:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Invalid CSS after "...er-radius:0 \0/": expected expression (e.g. 1px, bold), was ";}"
       (in /tmp/build_1k8ugei34dpcw/app/assets/stylesheets/application.css)

       Tasks: TOP => assets:precompile:primary
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文