1

我的 application.js 中有这个:

//= require jquery
//= require jquery_ujs
//= require prettyprint
//= require_tree .

这是我的生产配置:

  # Disable Rails's static asset server (Apache or nginx will already do this)
  config.serve_static_assets = false

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs
  config.assets.digest = true

当我推送到 Heroku 时,我得到:

-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_6a112dd5-b53f-4798-94d6-22ecc2b1edc4/Rakefile:7)
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_6a112dd5-b53f-4798-94d6-22ecc2b1edc4/Rakefile:7)
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_6a112dd5-b53f-4798-94d6-22ecc2b1edc4/Rakefile:7)
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_6a112dd5-b53f-4798-94d6-22ecc2b1edc4/Rakefile:7)
       Asset precompilation completed (3.37s)
-----> WARNINGS:
       Injecting plugin 'rails_log_stdout'
       Injecting plugin 'rails3_serve_static_assets'
       Add 'rails_12factor' gem to your Gemfile to skip plugin injection
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.0.0'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information."

但是当我在heroku中访问我的application.js时,文件是空白的。

更新

也许我没有提出这是我的问题,但 Heroku 现在需要:

gem 'rails_12factor', group: :production

在宝石文件中。我捆绑了。还没有工作。

我错过了什么?

4

3 回答 3

0

要么在生产环境中使用 Ruby 1.9.3,要么将你的 Rails 版本升级到3.2.14或更高版本。

旧版本的 Rails 不能很好地与 Ruby 2.0 配合使用。特别是链轮断裂:https ://github.com/sstephenson/sprockets/issues/352

将来,您应该考虑锁定您的 Ruby 版本,Gemfile以便在开发和生产中获得完全相同的体验。在您的 Gemfile 中添加:

ruby "2.0.0"
于 2013-09-21T02:08:07.980 回答
0

rake assets:precompile 您是否在部署前在您的 cmd 提示符中预编译了您的资产 ?

于 2013-09-18T22:15:36.173 回答
0

尝试替换以下内容:

Bundler.require(*Rails.groups(:assets => %w(development test)))

经过

Bundler.require(:default, :assets, Rails.env)

在你的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
于 2013-09-19T07:05:19.567 回答