こんにちは、Railsを独学で勉強している者です。
自作のRailsアプリをAWSのEC2を利用して本番環境にデプロイいたしました。
そこで1つ質問があります。
AWS上で以下のコマンドでプリコンパイルするとCSSは全て正常に表示されるのですが、
app/assets/imagesの中に保存した画像が表示されず、jQueryが全く動きません...(ちなみにローカルの開発環境では、app/assets/imagesの中に保存した画像も表示され、jQueryも正常に動きます。)
bundle exec rake assets:clobber RAILS_ENV=production bundle exec rake assets:precompile RAILS_ENV=production
nginxやunicornは正常に動いており、サイトは利用できます。
ファイルの中は以下の通りです。
config/environments/production.rb Rails.application.configure do config.cache_classes = true config.eager_load = true config.force_ssl = true config.consider_all_requests_local = false config.action_controller.perform_caching = true config.public_file_server.enabled = true config.assets.js_compressor = :uglifier config.assets.css_compressor = :sass config.assets.compile = true config.assets.digest = true host = 'xxx.com' config.action_mailer.default_url_options = { host: host } config.action_mailer.raise_delivery_errors = true config.log_level = :debug config.log_tags = [ :request_id ] config.action_mailer.perform_caching = false config.i18n.fallbacks = true config.active_support.deprecation = :notify config.log_formatter = ::Logger::Formatter.new if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end config.active_record.dump_schema_after_migration = false end
config/initializers/assets.rb Rails.application.config.assets.version = '1.0' Rails.application.config.assets.precompile += %w( admin_backend.css user_frontend.css admin_backend.js user_frontend.js )
nginxの設定ファイル upstream unicorn_server { server unix:/var/www/projects/christchurches-map/tmp/sockets/.unicorn.sock fail_timeout=0; } server { listen 80; client_max_body_size 4G; server_name IPアドレス; keepalive_timeout 5; # Location of our static files root /var/www/projects/アプリ名/public; location ~ ^/assets/ { root /var/www/projects/アプリ名/public; } location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; if (!-f $request_filename) { proxy_pass http://unicorn_server; break; } } error_page 500 502 503 504 /500.html; location = /500.html { root /var/www/projects/christchurches-map/public; } }
是非、アドバイスなどをよろしくお願いいたします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。