参考:http://www.oschina.net/question/146982_89497
因为项目没有数据库,所以就不能使用以前调用carriwave插件来实现上传功能
现简单文件上传到服务器(不用Gem或Plugin)
photo.html.erb:
<%= form_for @photo,:url=>{:action=>'create',:controller=>'photos'},:method=>post,:html=>{:multipart=true} do |f|%>
<%=f.file_field :photo%>
<%= f.submit %>
photos_controller.erb:
class PhotosController < ApplicationController
def create
require 'fileutils'
tmp=params[:image]
file=File.join('public',tmp.original_filename)
FileUtils.cp tmp.path,file
end
end