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

rake assets:precompile デプロイする前にコマンドプロンプトでアセットをプリコンパイル しましたか?

于 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 に答える