herokuエラー
解決したいこと
エラーの原因になっている画像部分をエラーなく表示させたい
)
Ruby on RailsでフリマWebアプリをつくっています。
本番環境で確認すると画像は表示されず文字だけ表示されておりクリックするとWe're sorry, but something went wrong.のエラーが発生しました。
https://gyazo.com/5cbd1a1e092f88f3da1eef700d732355
解決方法を教えて下さい。
発生している問題・エラー
ブラウザ We're sorry, but something went wrong.
ターミナルに出てきたエラー
https://gyazo.com/29202269d8b41a6771feca64d2e78ded
[1de2c273-a7fa-483e-9d32-9c7e33bfe467] ActionView::Template::Error (Can't resolve image into URL: to_model delegated to attachment, but attachment is nil):
該当するソースコード
<%= render "shared/header" %>
<%# 商品の概要 %>
<div class="item-show">
<div class="item-box">
<h2 class="name">
<%= @item.name %>
</h2>
<div class='item-img-content'>
<%= image_tag @item.image ,class:"item-box-img" %>
<div class='sold-out'>
<% if @item.order %>
<span>Sold Out!!</span>
</div>
<%end%>
</div>
<div class="item-price-box">
<span class="item-price">
¥<%=@item.price%>
</span>
<span class="item-postage">
<%= @item.shipping_charge.name %>
</span>
<% if user_signed_in? && @item.order == nil %>
<%if current_user.id == @item.user_id %>
<%= link_to '商品の編集', edit_item_path, method: :get, class: "item-red-btn" %>
<p class='or-text'>or</p>
<%= link_to '削除',item_path, method: :delete, class:'item-destroy' %>
<%else%>
<%= link_to '購入画面に進む',item_orders_path(item_id:@item.id) ,class:"item-red-btn"%>
<%end%>
<%end%>
<div class="item-explain-box">
<span><%= @item.description%></span>
</div>
</div>
<table class="detail-table">
<tbody>
<tr>
<th class="detail-item">出品者</th>
<td class="detail-value"><%=@item.user.nickname%></td>
</tr>
<tr>
<th class="detail-item">カテゴリー</th>
<td class="detail-value"><%= @item.category.name %></td>
</tr>
<tr>
<th class="detail-item">商品の状態</th>
<td class="detail-value"><%= @item.product_condition.name %></td>
</tr>
<tr>
<th class="detail-item">配送料の負担</th>
<td class="detail-value"><%= @item.shipping_charge.name %></td>
</tr>
<tr>
<th class="detail-item">発送元の地域</th>
<td class="detail-value"><%= @item.prefecture.name %></td>
</tr>
<tr>
<th class="detail-item">発送日の目安</th>
<td class="detail-value"><%= @item.day.name %></td>
</tr>
</tbody>
</table>
<div class="option">
<div class="favorite-btn">
<%= image_tag "star.png" ,class:"favorite-star-icon" ,width:"20",height:"20"%>
<span>お気に入り 0</span>
</div>
<div class="report-btn">
<%= image_tag "flag.png" ,class:"report-flag-icon" ,width:"20",height:"20"%>
<span>不適切な商品の通報</span>
</div>
</div>
</div>
<%# /商品の概要 %>
<div class="comment-box">
<form>
<textarea class="comment-text"></textarea>
<p class="comment-warn">
相手のことを考え丁寧なコメントを心がけましょう。
<br>
不快な言葉遣いなどは利用制限や退会処分となることがあります。
</p>
<button type="submit" class="comment-btn">
<%= image_tag "comment.png" ,class:"comment-flag-icon" ,width:"20",height:"25"%>
<span>コメントする<span>
</button>
</form>
</div>
<div class="links">
<a href="#" class="change-item-btn">
< 前の商品
</a>
<a href="#" class="change-item-btn">
後ろの商品 >
</a>
</div>
<%# 詳細ページで表示されている商品のカテゴリー名を表示しましょう %>
<a href=“#” class=‘another-item’><%= @item.category.name %>をもっと見る</a>
<%# //詳細ページで表示されている商品のカテゴリー名を表示しましょう %>
</div>
<%= render "shared/footer" %>
自分で試したこと
git push heroku master
heroku run rails db:migrate
0 likes