Rails:用回形针上传文件 [英] Rails: uploading files with paperclip
问题描述
class Cvit< ActiveRecord :: Base
has_attached_file:fileup,:path => :rails_root / public / data / 01_fasta
end
我失去了01_fasta目录,在做了一个chmod 777之后,我注意到这个文件在那里,但是它的名字像stream20110706-45944-12lt2oo-0
也尝试了#{rails_root}代替:rails_root。
什么是交易????
解决::url和:路径需要指向一个文件,而不是一个目录。所以我必须要有类似于
class Cvit< ActiveRecord :: Base
has_attached_file:fileup,
:url => /data/01_fasta/:basename.:extension,
:path => :rails_root / public / data / 01_fasta /:basename。:extension
end
:url和:路径需要指向一个文件,而不是一个目录。所以我必须要有类似于
class Cvit< ActiveRecord :: Base
has_attached_file:fileup,
:url => /data/01_fasta/:basename.:extension,
:path => :rails_root / public / data / 01_fasta /:basename。:extension
end
I would like to use paperclip to upload files. With the basic out of the box settings, I was able to get the file uploaded to the default directory (something in public/systems...) However when I tried changing the url or path (or both):
class Cvit < ActiveRecord::Base
has_attached_file :fileup, :path => ":rails_root/public/data/01_fasta"
end
I lose permission to the 01_fasta directory, after doing a chmod 777 on it, I notice the file is there but its named something like, stream20110706-45944-12lt2oo-0
also tried #{rails_root} in place of :rails_root.
Whats the deal????
SOLVED: the :url and :path need to point at a file, not a directory. So I had to have something like
class Cvit < ActiveRecord::Base
has_attached_file :fileup,
:url => "/data/01_fasta/:basename.:extension",
:path => ":rails_root/public/data/01_fasta/:basename.:extension"
end
the :url and :path need to point at a file, not a directory. So I had to have something like
class Cvit < ActiveRecord::Base
has_attached_file :fileup,
:url => "/data/01_fasta/:basename.:extension",
:path => ":rails_root/public/data/01_fasta/:basename.:extension"
end
这篇关于Rails:用回形针上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!