2009-06-04 6 views
1

나는Rails에서 파일 스트림이 열려 있는지 확인할 수 있습니까?

f = File.new(contacts_file_path, "wb") 
f.write params[:uploaded_file].read 
f.close 

나는

begin 
    f = File.new(contacts_file_path, "wb") 
    f.write params[:uploaded_file].read 
rescue 
    #error 
ensure 
    if f.open? then f.close end 
end 

그러나 f.open을 원했다? 함수가 아니며 API 문서를 찾을 수 없습니다. 어떤 아이디어?

답변

6
f.close unless f.closed? 
관련 문제