# Can write file via IRB, but not from actual controller...odd

**URL:** <https://www.ruby-forum.com/t/can-write-file-via-irb-but-not-from-actual-controller-odd/127387>\
**Category:** Rails\
**Created:** [January 28, 2008, 8:47pm UTC](https://www.ruby-forum.com/t/can-write-file-via-irb-but-not-from-actual-controller-odd/127387 "2008-01-28T20:47:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pyroblue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@pyroblue](https://www.ruby-forum.com/u/pyroblue)\
**Post date:** [January 28, 2008, 8:47pm UTC](https://www.ruby-forum.com/t/can-write-file-via-irb-but-not-from-actual-controller-odd/127387/1 "2008-01-28T20:47:28Z")

</div>

i have my rails app hosted at [eapps.com](http://eapps.com) (great folks) – but im running  
into an ODD issue…maybe someone can help.

if i go into IRB and type:

File.new(“temp.txt”, “w”)

, everything goes well, and it creates the file in the same directory  
that im in (in the controllers directory…bad, i know…but it works  
for now)…

now, in my controller, i have the exact same thing…but it wont create  
the file. no errors or anything…it just DOESNT create it…

ive chmod’d the directory to 777, but still to no avail…anyone got any  
ideas?

---

<div class="post-metadata">

**Author:** ![pyroblue](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f05b48/32.png) [@pyroblue](https://www.ruby-forum.com/u/pyroblue)\
**Post date:** [January 29, 2008, 5:49pm UTC](https://www.ruby-forum.com/t/can-write-file-via-irb-but-not-from-actual-controller-odd/127387/2 "2008-01-29T17:49:01Z")

</div>

Why are we creating a file anyway? Shouldn’t your data be stored in  
the database. Although I know I would need to create files for things  
like profile avatars, but I don’t know about this. Don’t forget to do  
file.close() or something similar, perhaps it’s not actually getting  
written until you do that? Also, maybe it’s being created in the /  
public/ directory, because that’s where the dispatch.cgi is running  
your program.

-Ryan

On Jan 28, 1:47 pm, Kasey M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
