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

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

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

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

Ruby

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

Q&A

解決済

1回答

273閲覧

Heroku Application Error "App Crashed!"

shirou

総合スコア15

Ruby on Rails 5

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

Ruby

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

0グッド

0クリップ

投稿2018/08/19 11:48

編集2018/08/20 11:25

前提・実現したいこと

gem Cloudinaryを追加してHerokuにデプロイ
実行環境は Rails5.2 加えてCarrierwave RMagick Minimagickがgemに存在。

発生している問題・エラーメッセージ

terminal

12018-08-19T11:04:06.504730+00:00 app[web.1]: /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant ImageUploader::Cloudinary (NameError) 22018-08-19T11:04:06.504835+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache' 32018-08-19T11:04:06.504866+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `rescue in load_missing_constant' 42018-08-19T11:04:06.504888+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:42:in `load_missing_constant' 52018-08-19T11:04:06.504908+00:00 app[web.1]: from /app/app/uploaders/image_uploader.rb:3:in `<class:ImageUploader>' 62018-08-19T11:04:06.504927+00:00 app[web.1]: from /app/app/uploaders/image_uploader.rb:1:in `<main>' 72018-08-19T11:04:06.504946+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' 82018-08-19T11:04:06.504966+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' 92018-08-19T11:04:06.504985+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' 102018-08-19T11:04:06.505005+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' 112018-08-19T11:04:06.505025+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' 122018-08-19T11:04:06.505064+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive' 132018-08-19T11:04:06.505045+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading' 142018-08-19T11:04:06.505084+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading' 152018-08-19T11:04:06.505104+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:43:in `load_missing_constant' 162018-08-19T11:04:06.505123+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:43:in `load_missing_constant' 172018-08-19T11:04:06.505162+00:00 app[web.1]: from /app/app/models/item.rb:1:in `<main>' 182018-08-19T11:04:06.505143+00:00 app[web.1]: from /app/app/models/item.rb:8:in `<class:Item>' 192018-08-19T11:04:06.505201+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi' 202018-08-19T11:04:06.505182+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require' 212018-08-19T11:04:06.505220+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register' 222018-08-19T11:04:06.505239+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi' 232018-08-19T11:04:06.505258+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require' 242018-08-19T11:04:06.505278+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading' 252018-08-19T11:04:06.505297+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive' 262018-08-19T11:04:06.505316+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/activesupport-5.2.1/lib/active_support/dependencies/interlock.rb:13:in `loading' 272018-08-19T11:04:06.505335+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:59:in `depend_on' 282018-08-19T11:04:06.505355+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!' 292018-08-19T11:04:06.505373+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:477:in `each' 302018-08-19T11:04:06.505403+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:477:in `block in eager_load!' 312018-08-19T11:04:06.505425+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:475:in `each' 322018-08-19T11:04:06.505444+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:475:in `eager_load!' 332018-08-19T11:04:06.505464+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/engine.rb:356:in `eager_load!' 342018-08-19T11:04:06.505503+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>' 352018-08-19T11:04:06.505483+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/application/finisher.rb:69:in `each' 362018-08-19T11:04:06.505522+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `instance_exec' 372018-08-19T11:04:06.505560+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:61:in `block in run_initializers' 382018-08-19T11:04:06.505579+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each' 392018-08-19T11:04:06.505541+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:32:in `run' 402018-08-19T11:04:06.505599+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' 412018-08-19T11:04:06.505618+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from' 422018-08-19T11:04:06.505637+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component' 432018-08-19T11:04:06.505656+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each' 442018-08-19T11:04:06.505675+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `call' 452018-08-19T11:04:06.505694+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component' 462018-08-19T11:04:06.505713+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each' 472018-08-19T11:04:06.505733+00:00 app[web.1]: from /app/vendor/ruby-2.5.1/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each' 482018-08-19T11:04:06.505752+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.5.0/gems/railties-5.2.1/lib/rails/initializable.rb:60:in `run_initializers'

先頭部分より

terminal

1 /app/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.3.1/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant ImageUploader::Cloudinary (NameError)

定義されていないImageUploader::Cloudinaryが原因のようです。

該当のソースコード

ruby

1image_uploader.rb 2class ImageUploader < CarrierWave::Uploader::Base 3 if Rails.env.production? 4 include Cloudinary::CarrierWave 5 process :convert => 'png' 6 process :tags => ['image'] 7 8 version :standard do 9 process :resize_to_fill => [100, 150, :north] 10 end 11 12 version :thumbnail do 13 process :resize_to_fit => [50, 50] 14 end 15 16 def public_id 17 return model.id 18 end 19 20 else 21 include CarrierWave::RMagick 22 process resize_to_fill: [128,128] 23 storage :file 24 # アップロードファイルの保存先ディレクトリは上書き可能 25 # 下記はデフォルトの保存先 26 def store_dir 27 "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" 28 end 29 # アップロード可能な拡張子のリスト 30 def extension_white_list 31 %w(jpg jpeg gif png) 32 end 33 end 34end

erb

1_form.html.erb 2<div class="field"> 3 <%= form.label :image %> 4 <%= form.file_field :image %> 5 <%= form.file_field :image, id: :items_image_path %> 6 </div>

ruby

1item.rb 2class Item < ApplicationRecord 3 # validates :name, presence: true 4 # validates :description, presence: true 5 # validates :price, presence:true 6 7 #for carrierwave to upload images 8 9 mount_uploader :image, ImageUploader 10 11 validate :add_error_sample 12 13 def add_error_sample 14 # nameが空のときにエラーメッセージを追加する 15 if name.blank? 16 errors[:base] << "商品名は必ず入力して下さい" 17 end 18 19 if description.blank? 20 errors[:base] << "説明文は必ず入力して下さい" 21 end 22 23 # 価格が空のときにエラーメッセージを追加する 24 if price.blank? 25 errors[:base] << "価格は必ず入力して下さい" 26 end 27 end 28end

試したこと

Qiitaにてまとめました
およそググって調べられるものは、Cloudinaryの追加段階でもエラーの連続でしたので試してみましたが解決には至りませんでした。

補足情報(FW/ツールのバージョンなど)

Rails5.2

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

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

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

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

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

guest

回答1

0

自己解決

自己解決しました。
肝心な、Gemfileの記述がありませんでした・・!
複数のエディタで別作業を行っていたのが原因です。お騒がせしました!

投稿2018/08/20 11:32

shirou

総合スコア15

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

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

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問