mini_magickをインストールし、画像のアップロードと表示をさせたいのですが以下のような画面に陥ってしまいます。これを解消しアップロードした画像そのものが表示されるようにしたいです。何卒よろしくお願いします!
該当するModel
class Member < ApplicationRecord has_secure_password has_many :entries, dependent: :destroy has_one_attached :profile_picture attribute :new_profile_picture validates :name, presence: true, format: { with: /\A[A-Za-z][A-Za-z0-9]*\z/, allow_blank: true, message: :invalid_member_name }, length: {minimum: 2, maximum: 20, allow_blank: true}, uniqueness: {case_sensitive: false} validates :email, email: {allow_blank: true} attr_accessor :current_password validates :password, presence: {if: :current_password} before_save do if new_profile_picture self.profile_picture = new_profile_picture end end class << self def search(query) rel = order("id") if query.present? rel = rel.where("name LIKE ? OR full_name LIKE ?", "%#{query}%", "%#{query}%") end rel end end end
該当するviewファイル
<tr> <th><%= form.label :new_profile_picture %></th> <td><%= form.file_field :new_profile_picture %></td> </tr>
<tr> <th>プロフィール画像</th> <td> <% if @member.profile_picture.attached?%> <%=image_tag @member.profile_picture.variant(resize: "128x128")%> <%end%> </td> </tr>
該当するストロングパラメーター
private def account_params params.required(:account).permit( :new_profile_picture, :name, :full_name, :birthday, :email ) end end
private def member_params attrs = [ :new_profile_picture, :name, :full_name, :birthday, :email, :administrator ]
##ソースコードのimageタグのurlを開くとでるエラー
cannot load such file -- mini_magick
あなたの回答
tips
プレビュー