[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails problem with select

RaW

11/14/2006 9:16:00 PM

A directory content:
$ ls -la
drwxr-xr-x 4 raw raw 4096 2006-11-14 00:00 .
drwxr-xr-x 5 raw raw 4096 2006-09-25 20:34 ..
drwxr-xr-x 2 raw raw 4096 2006-10-25 08:57 200406
-rw-r--r-- 1 raw raw 7800 2006-11-01 09:40 ajer.gif
-rw-r--r-- 1 raw raw 2550 2006-11-01 09:37 ajer_mini.gif
drwxr-xr-x 2 raw raw 4096 2006-11-14 00:00 test

Under irb:
irb(main):001:0> Dir.foreach("./") {|f| (puts f) if File.directory?(f)}
.
...
200406
test
=> nil

Part of Rails application:
<% dirs = [] %>
<% Dir.foreach("./") {|f| dirs.push(f) if File.directory?(f) }%>
<%= select 'photo', 'dirname', dirs, :id => 'photo_dirname' %>

HTML generated by Rails application (here is the problem - no 200406
directory):
<select id="photo_dirname" name="photo[dirname]">
<option value=".">.</option>
<option value="..">..</option>
<option value="test">test</option></select>

This is only the example. I have added some more subdirectories to that
directory (i've used many different names - not only numbers). But I
received the same strange behaviour. There are only some of the
directories in 'select' element. irb still works correct and shows all
directories but not Rails generated HTML code.
Note, that without:
if File.directory?(f)
'select' has all files and directories existed in current directory.
Does anyone could tell me what I am doing wrong?
Please note that I'm going to put all directories existed in current
directory in 'select' element (all directories and only directories).

Thanks in advance
--
RaW