# Calling File.read( ) from rails

**URL:** <https://www.ruby-forum.com/t/calling-file-read-from-rails/87172>\
**Category:** Rails\
**Created:** [February 28, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/calling-file-read-from-rails/87172 "2007-02-28T18:16:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [February 28, 2007, 6:16pm UTC](https://www.ruby-forum.com/t/calling-file-read-from-rails/87172/1 "2007-02-28T18:16:26Z")

</div>

I was looking at the encryption logic posted

[http://blog.leetsoft.com/2006/03/14/simple-encryption](http://blog.leetsoft.com/2006/03/14/simple-encryption)

and [http://blog.leetsoft.com/files/crypto-key.rb.txt](http://blog.leetsoft.com/files/crypto-key.rb.txt)

there is a call made to File.read( ) to open up RSA keys.  
THe question is:  
Does this result in an automatic closure of the file after it is  
read???

Or… if not should I do a File.open(), perform my logic, and then  
explicitly do a File.close() or wrap it in a block to close?

Concerned about a File descriptor leak.

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [March 2, 2007, 1:02am UTC](https://www.ruby-forum.com/t/calling-file-read-from-rails/87172/2 "2007-03-02T01:02:12Z")

</div>

DavidB wrote:

> there is a call made to File.read( ) to open up RSA keys.  
> THe question is: Does this result in an automatic closure of the file after it is read???

[http://www.ruby-doc.org/core/classes/IO.html#M002297](http://www.ruby-doc.org/core/classes/IO.html#M002297)

## –

Estamos de estreno… si necesitas llevar el control de tus gastos  
visita [http://www.gastosgem.com](http://www.gastosgem.com) !!Es gratis!!

---

<div class="post-metadata">

**Author:** ![DavidB](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/76d3ee/32.png) [@DavidB](https://www.ruby-forum.com/u/DavidB)\
**Post date:** [March 2, 2007, 5:08pm UTC](https://www.ruby-forum.com/t/calling-file-read-from-rails/87172/3 "2007-03-02T17:08:46Z")

</div>

Javier,  
Unbelievable-thanks for finding that. I thought I had scoured the API.  
Thanks again.  
David
