Rails资产管道不包括文件

时间:2013-09-18 19:22:36

标签: ruby-on-rails heroku asset-pipeline

我在我的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
Gemfile中的

。我捆绑了。还没有工作。

我错过了什么?

3 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分: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

答案 2 :(得分:0)

在生产中使用Ruby 1.9.3或将您的Rails版本升级到3.2.14或更高版本。

旧版本的Rails与Ruby 2.0不兼容。特别是链轮断裂:https://github.com/sstephenson/sprockets/issues/352

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

ruby "2.0.0"