1
carrierwave gem in rails를 사용하여 파일을 업로드하려고합니다. 사용자가 파일 만 업로드 할 수있게하고 싶습니다. 그래서 나는 아래와 같이 uploader의 extension_white_list 메소드를 사용했다. 하지만 또한 그것은 사용자가 이미지를 업로드 할 수 있습니다. 나는 여러 파일을 선택할 수 있도록하고 내 컨트롤러 코드는 아래와 같습니다.Carrierwave extension_white_list가 작동하지 않습니다.
내가 잘못 생각한 부분을 가르쳐 주시겠습니까?
미리 감사드립니다.
MyUploader.rb
def extension_white_list
%w(pdf doc htm html docx)
end
MyController.rb
def create
@store_id = ShopifyAPI::Shop.current.myshopify_domain
@store = Shop.find_by_shopify_domain(@store_id)
# @[email protected]
@attachment=params[:swatch][:attachment]
@attachment_json=[]
@attachment.each do |aa|
@swatch = Swatch.new(:store_id => @store.uuid,:attachment => aa)
@swatch.save
@attachment_json.push({ id: @swatch.id, url: @swatch.attachment.url})
end
render json: @attachment_json
end