Forum: Ruby on Rails File Iteration

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Newb N. (Guest)
on 2009-02-03 12:43
Hi all...
i have folder named test in my application's public folder .
i want to iterate that folder named test which is in public folder.
for that i tried this code it gives me error like


Errno::ENOENT

    in Chat logController#chat_log

</h1>
<pre>No such file or directory - /public/ACMServer_exe/ChatHistory</pre>



<p><code>RAILS_ROOT:
D:/Projects/inProgress/ANGACM0908/re/Task/acm_administration-31-jan-09</code></p
so how should i iterate the folder test which is in public folder


Thanks
Frederick C. (Guest)
on 2009-02-03 13:00
(Received via mailing list)
On 3 Feb 2009, at 10:43, Newb N. wrote:

>
> Hi all...
> i have folder named test in my application's public folder .
> i want to iterate that folder named test which is in public folder.
> for that i tried this code it gives me error like
>
What code :-) ? Dir.each, Dir.glob, Dir.entries can all be useful for
this sort of thing.

Fred
Newb N. (Guest)
on 2009-02-03 13:06
Frederick C. wrote:
> On 3 Feb 2009, at 10:43, Newb N. wrote:
>
>>
>> Hi all...
>> i have folder named test in my application's public folder .
>> i want to iterate that folder named test which is in public folder.
>> for that i tried this code it gives me error like
>>
> What code :-) ? Dir.each, Dir.glob, Dir.entries can all be useful for
> this sort of thing.
>
> Fred

Dir.foreach("/ACMServer_exe") do |folder_name|

does this code is correct.
but it gives me error.
 => this folder is in public folder => ACMServer_exe


pls help me
MaD (Guest)
on 2009-02-03 13:11
(Received via mailing list)
try this

Dir.foreach(RAILS_ROOT + '/public/javascripts') do |filename|
 puts filename
end
This topic is locked and can not be replied to.