rails6で作ったアプリを、はじめてherokuにpushしました。
だいたい動作しましたが、画像だけ表示できませんでした。
herokuのログを確認すると「RoutingError」が出てました。
商品登録でアップロードした画像で、出力はimage_tag()を使ってます。
エラーメッセージでググったものの、解決に至らず質問させていただきました。
分かる方教えていただけないでしょうか?
宜しくお願い致します。
2021-03-25T07:21:06.403247+00:00 app[web.1]: [cee0d905-af7d-44fd-ab94-0f4591c52789] app/controllers/items_controller.rb:9:in `show' 2021-03-25T07:21:06.405974+00:00 heroku[router]: at=info method=GET path="/items/1" host=gvgv.herokuapp.com request_id=cee0d905-af7d-44fd-ab94-0f4591c52789 fwd="58.13.43.197" dyno=web.1 connect=2ms service=199ms status=500 bytes=1891 protocol=https 2021-03-25T07:21:06.653694+00:00 app[web.1]: I, [2021-03-25T07:21:06.653546 #4] INFO -- : [4fca1a00-790c-4f27-b0ee-e561a4382ded] Started GET "/uploads/image/src/1/thumb_p7976-4.jpg" for 58.13.43.197 at 2021-03-25 07:21:06 +0000 2021-03-25T07:21:06.655908+00:00 app[web.1]: F, [2021-03-25T07:21:06.655835 #4] FATAL -- : [4fca1a00-790c-4f27-b0ee-e561a4382ded] 2021-03-25T07:21:06.655909+00:00 app[web.1]: [4fca1a00-790c-4f27-b0ee-e561a4382ded] ActionController::RoutingError (No route matches [GET] "/uploads/image/src/1/thumb_p7976-4.jpg"): 2021-03-25T07:21:06.655910+00:00 app[web.1]: [4fca1a00-790c-4f27-b0ee-e561a4382ded] 2021-03-25T07:21:06.658463+00:00 heroku[router]: at=info method=GET path="/uploads/image/src/1/thumb_p7976-4.jpg" host=gvgv.herokuapp.com request_id=4fca1a00-790c-4f27-b0ee-e561a4382ded fwd="58.13.43.197" dyno=web.1 connect=1ms service=9ms status=404 bytes=1966 protocol=https
\app\uploaders\image_uploader.rb
ruby
1 2class ImageUploader < CarrierWave::Uploader::Base 3 4 include CarrierWave::MiniMagick 5 6 process resize_to_fill: [600, 600, "Center"] 7 8 # Choose what kind of storage to use for this uploader: 9 storage :file 10 # storage :fog 11 12 # Override the directory where uploaded files will be stored. 13 # This is a sensible default for uploaders that are meant to be mounted: 14 def store_dir 15 "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" 16 end 17 18 19 # Create different versions of your uploaded files: 20 version :thumb do 21 process resize_to_fit: [50, 50] 22 end 23 24 # Add a white list of extensions which are allowed to be uploaded. 25 # For images you might use something like this: 26 def extension_whitelist 27 %w(jpg jpeg gif png) 28 end 29 30 # Override the filename of the uploaded files: 31 # Avoid using model.id or version_name here, see uploader/store.rb for details. 32 # def filename 33 34 35end 36
app\views\items\show.html.erb
ruby
1 <%= image_tag image.src.to_s, class: "item-show__img-bg", alt: @item.title %> 2
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。