我正在使用钛进行图像捕获,然后使用 ruby on rails 上传。在钛中捕获图像后,我只需点击/img_uploaders/upload
rails 的 URL 即可调用。结果,发送了对该upload
方法的发布请求。
这就是我在控制台中得到的:-
Started POST "/img_uploaders/upload" for 192.168.0.180 at 2012-12-19 20:40:31 +0
530
Processing by ImgUploadersController#upload as MULTIPART_FORM
Parameters: {"media"=>#<ActionDispatch::Http::UploadedFile:0x569e308 @original
_filename="tixhr1442726854.jpeg", @content_type="image/jpeg", @headers="Content-
Disposition: form-data; name=\"media\"; filename=\"tixhr1442726854.jpeg\"\r\nCon
tent-Type: image/jpeg\r\nContent-Transfer-Encoding: binary\r\n", @tempfile=#<Fil
e:C:/Users/user/AppData/Local/Temp/RackMultipart20121219-3924-is4hsq>>}
←[1m←[35m (49.0ms)←[0m BEGIN
←[1m←[36mSQL (82.0ms)←[0m ←[1mINSERT INTO `img_uploaders` (`avatar_content_ty
pe`, `avatar_file_name`, `avatar_file_size`, `avatar_updated_at`, `created_at`,
`name`, `path`, `type`, `updated_at`) VALUES (NULL, NULL, NULL, NULL, '2012-12-1
9 15:10:31', NULL, NULL, NULL, '2012-12-19 15:10:31')←[0m
←[1m←[35m (141.0ms)←[0m COMMIT
Redirected to http://192.168.0.187:3000/
Completed 302 Found in 858ms (ActiveRecord: 277.0ms)
如上面的控制台输出所示,该表正在获取图像路径和图像名称的空值。我不知道我的图像存储在哪里以及如何获取图像位置的路径。
这是我upload
被调用的方法:-
def upload
@photo = ImgUploader.new(:avatar => params[:media])
if @photo.save
redirect_to root_url
else
render :action => 'new'
end
end