Topic: Creating custom files within a rails app

Hi

I have a podcast website and I want to generate an XSPF file whenever I am uploading a new podcast to the site.

Currently I do this manually by going to my public/media folder and creating a new .xspf file.

Is it possible to automatically create new files in the public folder from my app, or do I have to continue doing this by hand?

Any tutorials on this sort of thing?

Re: Creating custom files within a rails app

So far I've foudn this:

File.open(local_filename, 'w') {|f| f.write(doc) }

It looks promising.

My main issue though is that I want to generate this file and store it in my public folder. I know that that paperclip can save files to this folder so I will probably just hack their code up in the end and steal it.

Re: Creating custom files within a rails app

Foudn this somewhere else, it might work - will try it later and update:


try
      File.makedirs("#{RAILS_ROOT}/public/report")
      File.open("#{RAILS_ROOT}/public/report/waiting.adc", "w") { |file| file.write("hello world") }
end

Re: Creating custom files within a rails app

People should learn how to use a programming language's api. Especially when Ruby's one is well documented.