Topic: Creating Dynamic directories

Hi.. Everybody

I am very new to this rails frame work and currently working on my 1st rails application and stuck with confusion of the best way of creating dymanic directory structure

the directory structure which I have to create in my application is like

/year/month/day/filename.txt

that is my application should take the numeric values of year/month/day of that time .

In nutt shell

1. "How to create directories in rails ?"
2.  "How to assign year/month/day values to the directories while creating them?"

so please if anybody could guide me the efficient strategy of creating such directories ,
Thanks smile

Last edited by cyberyogi (2011-09-19 08:21:17)

Re: Creating Dynamic directories

paperclip will handle file storage as well as image storage for you automatically. I don;t normally recommend gems as doing things tyourself gives you way more control but this is definitely one exception.

More info here http://railscasts.com/episodes/134-paperclip

Otherwise check out ruby file I/O handling here
http://www.tutorialspoint.com/ruby/ruby … output.htm

What you want and what you need are too often not the same thing!
When your head is hurting from trying to solve a problem, stop standing on it. When you are the right way up you will see the problem differently and you just might find the solution.
(Quote by me 15th July 2009)

Re: Creating Dynamic directories

@jamesw

I did it with  your second suggestion of I/O handling smile
and paperclip plugin would be useful for next module on which I am working on smile

Thank you Very much for ur reply smile