Ruby on Rails 回形针问题 [英] Ruby on Rails paperclip questions
本文介绍了Ruby on Rails 回形针问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用回形针将文件上传到服务器.现在错误都清除了,但是不知道怎么设置上传路径.
I want to use paperclip to upload files to server. Errors are all cleaned now, but I don't know how to set the upload path.
我的代码如下所示:
上传类:
puts has_attached_file :image, :default_url => :file_system
validates_attachment_content_type :image, :content_type => [:image, 'audio/mpeg', 'application/mp3', 'application/octet-stream']
我想将上传的内容保存在 project/public/uploads 中.
I want to save uploads in project/public/uploads.
我怎样才能意识到这一点?
How can I realise this?
推荐答案
那么它应该是这样的:
has_attached_file :image,
:path => ":rails_root/public/uploads/:filename",
:url => "/uploads/:filename"
这篇关于Ruby on Rails 回形针问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文