Ruby on Rails paperclip questions

霸气de小男生 提交于 2020-01-25 20:15:08

问题


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.

My code looks like this:

upload class:

  puts has_attached_file :image, :default_url => :file_system
  validates_attachment_content_type :image, :content_type => [:image,    'audio/mpeg', 'application/mp3', 'application/octet-stream']

I want to save uploads in project/public/uploads.

How can I realise this?


回答1:


Then it should look like this:

has_attached_file :image,                     
                    :path => ":rails_root/public/uploads/:filename",
                    :url => "/uploads/:filename"  


来源:https://stackoverflow.com/questions/29736467/ruby-on-rails-paperclip-questions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!