@inrmnn

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

デフォルトプロフィール画像が変わらない

railsでアプリケーションを作成しています
active storageを使ってデフォルトのプロフィール画像を表示させているのですが
以前の画像から新しい画像に変えようと思い、以前の画像をフォルダーから削除し、新しい画像をフォルダーにアップロードしました。
ですがリロード rails s を実行しても以前の画像のままになってしまいます
どうすれば良いでしょうか
よろしくお願いいたいします

class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :validatable
  
  has_many :books, dependent: :destroy
  
  has_one_attached :profile_image
 
  
  def get_profile_image(width, height)
    unless profile_image.attached?
      file_path = Rails.root.join('app/assets/images/no-image.jpeg')
      profile_image.attach(io: File.open(file_path), filename: 'default-image.jpg', content_type: 'image/jpeg')
    end
    profile_image.variant(resize_to_limit: [width, height]).processed
  end
  
  
end
0 likes

2Answer

正常にファイルがアタッチされていない可能性はないでしょうか。

以下のテーブル内情報は更新されているか確認済みでしょうか。

active_storage_blobs
active_storage_variant_records
active_storage_attachments

0Like

Your answer might help someone💌