Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Read files in directory on ruby on rails

I am new in ruby on rails and I want to read file names from a specified directory. Can anyone suggest code or any other links?

Thanks

like image 335
Adnan Khan Avatar asked Jun 06 '11 15:06

Adnan Khan


People also ask

How do I view files in Rails?

For security reason, you can not access a file outside project rails from URL without defining a route. What you can do, is point a route to controller that, based on file name provided at url, require a file outside rails project.


1 Answers

I suggest you use Dir.entries("target_dir")

Check the documentation here

like image 150
Stobbej Avatar answered Oct 03 '22 13:10

Stobbej