저는 보통 Carrierswave with Rails를 사용합니다. < = 4, 그러나 지금은 Rails 5 프로젝트에서 작업 중입니다. 난 더 이상 이미지를 업로드 할 수 없습니다 나는 ActiveAdmin을에서 시도 여러 오류 ((정의되지 않은 방법지도 및 시드 파일)을 얻고 사람이 알고 있나요 어떻게 어디에서 오류가 사용Carrierwave Image Upload & Rails 5 정의되지 않은 메소드`map '
버전입니다.?
Ruby 2.4.1p111
Rails 5.02
Carrierwave 1.1.0
ActiveAdmin from Github Master Repo
평소처럼
나는 나의 업 로더를 생성하고 내 모델에 장착.
업 로더/StoreImageUploader.rb
class StoreImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Create different versions of your uploaded files:
version :thumb do
process resize_to_fit: [250, 250]
end
end
모델/store.rb
class Store < ApplicationRecord
mount_uploaders :image, StoreImageUploader
serialize :image, JSON # If you use SQLite, add this line.
belongs_to :organization
has_many :orders
end
보통 ActiveAdmin을이 시간을 자동으로 :file
에 image:string
필드를 설정 mounted uploaders
있고 감지하지만.
수동으로 활성 관리 파일을 조정했습니다.
관리/store.rb 내가 오류 다음 얻을 업로드
ActiveAdmin.register Store do
permit_params :name , :image
form(:html => { :multipart => true }) do |f|
f.inputs "Store" do
f.input :name
f.input :image, :as => :file
end
f.button "Create"
end
end
했다 ':) – zer02