1

プロダクション モードのアセット パイプラインに問題があります。私はbundle exec rake assets:precompile開発を実行しましたが、正常に動作します。ただし、本番サーバーで実行すると(デプロイ後)、cssおよびjsファイルが正しくロードされません。url を介して css または js ファイルにアクセスする/assets/[file_name]と、500 エラーが発生します。権限の問題だと思いましたが、その下のすべてのファイル/public/assetsにアクセスできます。Production.rb および development.rb ファイルはすべて無傷です (足場から)。ただし、htmlにリストされているすべてのファイルを見ることができます。どんなヒントでも大歓迎です。ありがとう

production.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 = false

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

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

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

Gemfile(スナップショット):

gem 'rails', '3.2.11'

gem 'pg'
gem 'json'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
#  gem 'therubyracer'

  gem 'uglifier', '>= 1.0.3'
end

gem 'compass-rails'
# Deployment related
gem 'capistrano'
gem 'capistrano-ext'

gem 'jquery-rails', '~> 2.0.0'
gem 'jquery-datatables-rails'

group :development do
  gem 'guard'
end

アプリケーション.css:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require dataTables/jquery.dataTables
 *= require bootstrap.scss
 *= require bootstrap-responsive.scss
 *= require_tree .
 */

Sass関連の別のapplication.css.scssがあります:

@import "compass";
@import "compass/utilities/tables";

.ftr-ticker {
  background: #333;
  height: 25px;
  width: 100%;
}
....
4

1 に答える 1

1

マニフェスト ファイルを変更したためapplication.css、問題が発生したと思います。私のアドバイスは、scssファイルの名前を ではなく 他の名前に変更しapplication(可能性がありますcustom.css.scss)、次のようにマニフェストapplication.cssファイルに含めることです。

*= require custom

ご覧のとおり、スタイルシート ファイルの名前にはプレフィックスが付いていません。あなたの*= require bootstrap.scssはずです*= require bootstraprequire_tree他の人が必要とするすべての後に移動することもお勧めします。この Railsguideは、Rails 3.2 のアセット パイプラインを支援します。

于 2013-02-11T00:34:21.053 に答える