# Rails problem with select

**URL:** <https://www.ruby-forum.com/t/rails-problem-with-select/75986>\
**Category:** Ruby\
**Created:** [November 14, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/rails-problem-with-select/75986 "2006-11-14T22:22:08Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RaW](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6bbea6/32.png) [@RaW](https://www.ruby-forum.com/u/RaW)\
**Post date:** [November 14, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/rails-problem-with-select/75986/1 "2006-11-14T22:22:08Z")

</div>

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):

. .. test

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
