質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Amazon S3

Amazon S3 (Simple Storage Service)とはアマゾン・ウェブ・サービスが提供するオンラインストレージサービスです。

Q&A

0回答

1544閲覧

Rails Tutorial13章でCarrierWaveを使って本番環境(heroku)での画像投稿の設定をした後デプロイできなくなりました。

sassan738

総合スコア32

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Amazon S3

Amazon S3 (Simple Storage Service)とはアマゾン・ウェブ・サービスが提供するオンラインストレージサービスです。

0グッド

0クリップ

投稿2019/10/06 20:50

現在Cloud9上でRails Tutorialを勉強しているのですが、13章で画像投稿のためのセッティングをして、git push heroku コマンドをしたところ、デプロイできませんでした。
現在の状況はCloud9上のサーバーでは画像投稿含めて正常に動作していて、テストも通っています。
AWSでIAMとS3バケットを作成して、herokuに環境変数を設定しました。

最初にデプロイした時にコンソール上のメッセージでfogではなくfog-awsというgemを使用するように指示があったため、以下の記事をもとに設定を行いました。
QiitaのCarrierWaveに関する記事
13章でデプロイできない旨の他の人の質問

デプロイした時のコンソール上のメッセージは以下の通りです。

ec2-user:~/rails-tutorial/sample_app09 (master) $ git push heroku Counting objects: 17370, done. Compressing objects: 100% (8539/8539), done. Writing objects: 100% (17370/17370), 26.10 MiB | 24.34 MiB/s, done. Total 17370 (delta 7601), reused 17314 (delta 7554) remote: Compressing source files... done. remote: Building source: remote: remote: ! Warning: Multiple default buildpacks reported the ability to handle this app. The first buildpack in the list below will be used. remote: Detected buildpacks: Ruby,Node.js remote: See https://devcenter.heroku.com/articles/buildpacks#buildpack-detect-order remote: -----> Ruby app detected remote: -----> Compiling Ruby/Rails remote: -----> Using Ruby version: ruby-2.5.6 remote: -----> Installing dependencies using bundler 1.17.3 remote: Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment remote: The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. remote: Fetching gem metadata from https://rubygems.org/............ remote: Fetching rake 13.0.0 remote: Installing rake 13.0.0 省略 remote: Fetching sass-rails 5.0.6 remote: Installing sass-rails 5.0.6 remote: Bundle complete! 29 Gemfile dependencies, 74 gems now installed. remote: Gems in the groups development and test were not installed. remote: Bundled gems are installed into `./vendor/bundle` remote: Post-install message from sass: remote: remote: Ruby Sass has reached end-of-life and should no longer be used. remote: remote: * If you use Sass as a command-line tool, we recommend using Dart Sass, the new remote: primary implementation: https://sass-lang.com/install remote: remote: * If you use Sass as a plug-in for a Ruby web framework, we recommend using the remote: sassc gem: https://github.com/sass/sassc-ruby#readme remote: remote: * For more details, please refer to the Sass blog: remote: https://sass-lang.com/blog/posts/7828841 remote: remote: Bundle completed (50.05s) remote: Cleaning up the bundler cache. remote: -----> Installing node-v10.15.3-linux-x64 remote: -----> Detecting rake tasks remote: -----> Preparing app for Rails asset pipeline remote: Running: rake assets:precompile remote: rake aborted! remote: LoadError: cannot load such file -- fog remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `block in require' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:258:in `load_dependency' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/activesupport-5.1.6/lib/active_support/dependencies.rb:292:in `require' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:122:in `eager_load_fog' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/carrierwave-1.2.2/lib/carrierwave/uploader/configuration.rb:137:in `fog_credentials=' 省略 remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:329:in `require_environment!' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/railties-5.1.6/lib/rails/application.rb:445:in `block in run_tasks_blocks' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define' remote: /tmp/build_680f40062a50379ed085c7412ffe8cba/vendor/bundle/ruby/2.5.0/gems/rake-13.0.0/exe/rake:27:in `<top (required)>' remote: Tasks: TOP => environment remote: (See full trace by running task with --trace) remote: remote: ! remote: ! Precompiling assets failed. remote: ! remote: ! Push rejected, failed to compile Ruby app. remote: remote: ! Push failed remote: Verifying deploy... remote: remote: ! Push rejected to murmuring-dawn-26950. remote: To https://git.heroku.com/murmuring-dawn-26950.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/murmuring-dawn-26950.git'

Gemfileです。

source 'https://rubygems.org' gem 'rails', '5.1.6' gem 'bcrypt', '3.1.12' gem 'faker', '1.7.3' gem 'carrierwave', '1.2.2' gem 'mini_magick', '4.7.0' gem 'will_paginate', '3.1.6' gem 'bootstrap-will_paginate', '1.0.0' gem 'bootstrap-sass', '3.3.7' gem 'puma', '3.9.1' gem 'sass-rails', '5.0.6' gem 'uglifier', '3.2.0' gem 'coffee-rails', '4.2.2' gem 'jquery-rails', '4.3.1' gem 'turbolinks', '5.0.1' gem 'jbuilder', '2.7.0' group :development, :test do gem 'sqlite3', '1.3.13' gem 'byebug', '9.0.6', platform: :mri end group :development do gem 'web-console', '3.5.1' gem 'listen', '3.1.5' gem 'spring', '2.0.2' gem 'spring-watcher-listen', '2.0.1' end group :test do gem 'rails-controller-testing', '1.0.2' gem 'minitest', '5.10.3' gem 'minitest-reporters', '1.1.14' gem 'guard', '2.14.1' gem 'guard-minitest', '2.4.6' end group :production do gem 'pg', '0.20.0' gem 'fog-aws' end # Windows環境ではtzinfo-dataというgemを含める必要があります gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

sample_app/config/initializers/carrier_wave.rbの設定です。

if Rails.env.production? require 'carrierwave/storage/abstract' require 'carrierwave/storage/file' require 'carrierwave/storage/fog' CarrierWave.configure do |config| config.fog_credentials = { # Amazon S3用の設定 :provider => 'AWS', :region => ENV['ap-northeast-1'], # 例: 'ap-northeast-1' :aws_access_key_id => ENV['割愛'], :aws_secret_access_key => ENV['割愛'] } config.fog_directory = ENV['割愛'] config.storage :fog config.fog_provider = 'fog/aws' end end

sample_app/app/uploaders/picture_uploader.rbの設定です。

class PictureUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick process resize_to_limit: [400, 400] # Choose what kind of storage to use for this uploader: if Rails.env.production? storage :fog else storage :file end # storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end # Add a white list of extensions which are allowed to be uploaded. # For images you might use something like this: def extension_whitelist %w(jpg jpeg gif png) end end

12章が終わった時点でローカル環境の調子が悪くなり、13章からCloud9に引越ししました。あと、最初にデプロイできなかった時に、もともと作成していたherokuのリモートディレクトリと齟齬があったことが原因かと思って、紐づけを解除してheroku createで新たにheroku上にディレクトリを作りました。その事が関係あるのか分かりませんが一応情報としてお伝えします。
何を調べてよいのか見当がつかないので、何かアドバイスが頂ければありがたいです。
よろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問