# File manipulation

**URL:** <https://www.ruby-forum.com/t/file-manipulation/98086>\
**Category:** Rails\
**Created:** [July 12, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086 "2006-07-12T14:49:02Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 12, 2006, 2:49pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/1 "2006-07-12T14:49:02Z")

</div>

What are the possibilities of file manipulation in RoR? How do you  
create a .html or .rhtml file with ruby to be placed in the public  
folder, with custom content?

Btw, where is RoR root? Is that ‘public’?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 12, 2006, 4:06pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/2 "2006-07-12T16:06:35Z")

</div>

On Jul 12, 2006, at 14:49, Pål Bergström wrote:

> What are the possibilities of file manipulation in RoR? How do you  
> create a .html or .rhtml file with ruby to be placed in the public  
> folder, with custom content?
> 
> Btw, where is RoR root? Is that ‘public’?

Yes, to get a normalized absolute path:

File.expand\_path(RAILS\_ROOT)

– fxn

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 12, 2006, 10:51pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/3 "2006-07-12T22:51:01Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> What are the possibilities of file manipulation in RoR? How do you  
> create a .html or .rhtml file with ruby to be placed in the public  
> folder, with custom content?

And what about file manipulation, creating a file (but maybe better in  
the views folder)?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 12, 2006, 11:14pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/4 "2006-07-12T23:14:31Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> PÃ¥l BergstrÃ¶m wrote:
> 
> > What are the possibilities of file manipulation in RoR? How do you  
> > create a .html or .rhtml file with ruby to be placed in the public  
> > folder, with custom content?
> 
> And what about file manipulation, creating a file (but maybe better in  
> the views folder)?

Think I understand it now. Found the answer in  
[http://corelib.rubyonrails.org/](http://corelib.rubyonrails.org/) using File class.

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 13, 2006, 3:09pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/5 "2006-07-13T15:09:04Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> PÃ¥l BergstrÃ¶m wrote:
> 
> > PÃ¥l BergstrÃ¶m wrote:
> > 
> > > What are the possibilities of file manipulation in RoR? How do you  
> > > create a .html or .rhtml file with ruby to be placed in the public  
> > > folder, with custom content?
> > 
> > And what about file manipulation, creating a file (but maybe better in  
> > the views folder)?
> 
> Think I understand it now. Found the answer in  
> [http://corelib.rubyonrails.org/](http://corelib.rubyonrails.org/) using File class.

Didn’t work. Could someone explain how you create a file?

---

<div class="post-metadata">

**Author:** ![paulbutcher](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@paulbutcher](https://www.ruby-forum.com/u/paulbutcher)\
**Post date:** [July 13, 2006, 7:46pm UTC](https://www.ruby-forum.com/t/file-manipulation/98086/6 "2006-07-13T19:46:02Z")

</div>

PÃ¥l BergstrÃ¶m wrote:

> PÃ¥l BergstrÃ¶m wrote:
> 
> > PÃ¥l BergstrÃ¶m wrote:
> > 
> > > PÃ¥l BergstrÃ¶m wrote:
> > > 
> > > > What are the possibilities of file manipulation in RoR? How do you  
> > > > create a .html or .rhtml file with ruby to be placed in the public  
> > > > folder, with custom content?
> > > 
> > > And what about file manipulation, creating a file (but maybe better in  
> > > the views folder)?
> > 
> > Think I understand it now. Found the answer in  
> > [http://corelib.rubyonrails.org/](http://corelib.rubyonrails.org/) using File class.
> 
> Didn’t work. Could someone explain how you create a file?

Now it did. Worked when I used “w” instead of “r” in  
File.new(“name”,“w”)
