我已将 Rails 3.0 应用程序迁移到 Heroku 上的 3.1。它在 cedar 堆栈上运行,除了应用程序的 javascript 无法运行外,一切都很好。 application.js 文件已编译,看起来就像它应该的那样。可以通过访问 myapp.com/assets/application.js 访问它。它就是无法运行!
如果我在本地运行该应用程序,javascript 可以运行,所以我怀疑一定是我遗漏了一些简单的配置问题。这是我的 production.rb 文件:
FloridaBirdTrail::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = true
# Compress JavaScripts and CSS
config.assets.compress = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end
编辑
将 production.rb 的内容替换为 development.rb 的内容至少允许我的一些 javascript 运行(由于某种原因,gmap3 不工作)。但哪些设置会产生影响?
最佳答案
打开您的 application.rb
文件并确保您的 Bundler
require 语句如下所示:
Bundler.require *Rails.groups(:assets)
默认情况下它看起来像
# 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)
关于javascript 没有在带有 rails 3.1 的 heroku 上运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7489136/