为什么 Heroku 在 Rails 3.1 应用程序中跳过预编译步骤?

发布于 2024-12-07 19:39:03 字数 1383 浏览 0 评论 0原文

我正在摆弄 Rails 3.1 应用程序并部署到 Heroku Cedar。

推送应用程序时,Heroku 会跳过预编译步骤,而不会引发错误:

Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 16.2MB
-----> Launching... done, v35

我上次推送到 Heroku 时(可能是一个月前),预编译资产没有问题。

gem 'rails', '3.1.1.rc2', :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable'

更新:

我能够通过从 application.rb: 中删除以下内容

 if defined?(Bundler)
   # If you precompile assets before deploying to production, use this line
   Bundler.require *Rails.groups(:assets => %w(development test))
   # If you want your assets lazily compiled in production, use this line
   # Bundler.require(:default, :assets, Rails.env)
 end

并替换为:

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require *Rails.groups(:assets) if defined?(Bundler)

I'm messing around with a rails 3.1 app and deploying to Heroku Cedar.

When pushing an app, Heroku skips over the precompile step without throwing an error:

Your bundle is complete! It was installed into ./vendor/bundle
Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Rails plugin injection
       Injecting rails_log_stdout
       Injecting rails3_serve_static_assets
-----> Discovering process types
       Procfile declares types      -> (none)
       Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 16.2MB
-----> Launching... done, v35

The last time I pushed to Heroku (maybe a month ago) it had no problem precompiling assets.

gem 'rails', '3.1.1.rc2', :git => 'git://github.com/rails/rails.git', :branch => '3-1-stable'

UPDATE:

I was able to get Heroku to precompile by removing the following from application.rb:

 if defined?(Bundler)
   # If you precompile assets before deploying to production, use this line
   Bundler.require *Rails.groups(:assets => %w(development test))
   # If you want your assets lazily compiled in production, use this line
   # Bundler.require(:default, :assets, Rails.env)
 end

and replacing with:

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require *Rails.groups(:assets) if defined?(Bundler)

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

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

发布评论

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

评论(2

丢了幸福的猪 2024-12-14 19:39:03

我知道这可能听起来很自负,但是您确定使用 -stack cedar 创建了 Heroku 应用程序吗?

I know this may sound conceiting, but did you make sure you create the Heroku app with -stack cedar?

乙白 2024-12-14 19:39:03

您还可以检查链轮是否已启用,就像我一样 这里当我遇到同样的问题时。

You could also check to see that sprockets is enabled as I did here when I was having the same problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文