2016-11-02 32 views
0

私は宝石CarrierWaveを使用して複数のファイルをアップロードしましたが、アップロードできますが、それぞれのアドレスをダウンロードして表示することはできません。複数のファイル配列を表示する方法はCarrierWaveによってアップロードされましたか?

私は、コンソールディスプレイにアップロードしたファイルの配列を使用することを試みたが、私はこれだ:私は、ファイルのアドレスが間違っている一つのファイルをアップロードすると、ファイル名が

なります

2.2.4 :013 > Legislation.find(14).documents.each do |doc| 
2.2.4 :014 >  puts doc 
2.2.4 :015?> end 
    Legislation Load (0.4ms) SELECT "legislations".* FROM "legislations" WHERE "legislations"."id" = ? LIMIT 1 [["id", 14]] 
/uploads/legislation/documents/14/%5B%2267490.jpg%22%2C%20%2214536943_1300076803359446_1963523476_o.jpg%22%2C%20%221436764358456.jpg%22%2C%20%22ch_09b.ppt%22%5D 
=> [#<DocumentUploader:0x007fc5c7b6bcc0 @model=#<Legislation id: 14, title: "ascsf", created_at: "2016-11-02 08:51:39", updated_at: "2016-11-02 08:51:39", attachment: nil, documents: "[\"67490.jpg\", \"14536943_1300076803359446_196352347...">, @mounted_as=:documents, @storage=#<CarrierWave::Storage::File:0x007fc5c7b6bbf8 @uploader=#<DocumentUploader:0x007fc5c7b6bcc0 ...>>, @file=#<CarrierWave::SanitizedFile:0x007fc5c7b6b2e8 @file="/Users/ChamperWu/projects/nsysu_mem/public/uploads/legislation/documents/14/[\"67490.jpg\", \"14536943_1300076803359446_1963523476_o.jpg\", \"1436764358456.jpg\", \"ch_09b.ppt\"]", @original_filename=nil, @content_type=nil>, @versions={}>] 

% 5B%2267490.jpgの%22%2C%、20%

ない実名

67490.jpg

コントローラー:

def legislation_params 
    params.require(:legislation).permit(:title, :attachment, {documents: []}) 
end 

モデル:

class Legislation < ActiveRecord::Base 
    mount_uploader :attachment, AttachmentUploader 
    mount_uploaders :documents, DocumentUploader 
    validates :title, presence: true 
end 

移行:

class AddDocmentToLegislations < ActiveRecord::Migration 
    def change 
    add_column :legislations, :documents, :string, array: true, default: [] 
    end 
end 

私はそれを解決することができますか?

答えて

1

私は公式問題hereで同じ質問を見つけた、と私はモデルにserialize :documentsを追加し、すべての質問が

を行っている問題

を解決

関連する問題