Trying to get the files in a directory structure to be read into a variable. Just playing around right now but would like it so that each file read gets entered into a database. Trying to read a folder of music files. I put the folder in the public folder along with the images, and stylesheet. Added this code to my controller: @files = Dir[''/public/music/''] @mp3 = @files.select{ |my_file| /(mp3|MP3)$/ =~ my_file } And added thsi code to my view: <%= @mp3.select{ |file| /(mp3|MP3)$/ =~ file } %> but nada. Any suggestions? Where do I put the folder. If it is in my puiblic folder, am I referencing it right in my view? Thanks -Shandy -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> @files = Dir[''/public/music/'']just guessing, but one possible reason this isn''t working is the path from the controller is relative to the ''app'' path ... something like this should work (extremely untested): @files = Dir[ RAILS_ROOT + ''/public/music'' ] anyway, the problem lies within. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> @files = Dir[ RAILS_ROOT + ''/public/music'' ]I have tried that and what I get back is ''[].'' I assume that means that its not finding anything in the directory even though there is stuff there. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---