###前提・実現したいこと
本番環境で画像を表示したいです。
###発生している問題・エラーメッセージ
ActionController::RoutingError (No route matches [GET] "/system/microposts/photos/000/000/005/medium/81306024002557.jpg"):
実際のファイルは
/home/anime/text/current/public/system/microposts/photos/000/000/005/medium以下に存在します。
###該当のソースコード
【micropost.rb】
class Micropost < ApplicationRecord belongs_to :user validates :user_id, presence: true validates :content, presence: true, length: { maximum: 140} default_scope -> { order(created_at: :desc)} # photoをattachファイルとする。stylesで画像サイズを定義できる has_attached_file :photo, :styles => { medium: "300x300>", thumb: "100x100>" }, # 画像サイズを指定 :url => "/assets/arts/:id/:style/:basename.:extension", # 画像保存先のURL先 :path => "#{Rails.root}/public/assets/arts/:id/:style/:basename.:extension" # サーバ上の画像保存先パス # ファイルの拡張子を指定(これがないとエラーが発生する) validates_attachment :photo, content_type: { content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"] } end
【microposts/show.html.erb】
has_attached_file :photo, styles: { medium: "300x300>", thumb: "100x100>" }
パスはあっていると思うのですが。。。
assets/image以下の画像ファイルは正常に読み込むことができます。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/02/27 02:58
2017/02/27 03:02
2017/02/27 04:56
2017/02/27 04:57
2017/02/27 05:06
2017/02/27 05:32