I have a client that uses SQL Server Reporting Services to generate reports and exports them in MHTML. The Client wants to just push the MHTML in a pre-defined directory structure to my Rails public/reports folder.
Is there any way in Rails to "Take in" the directory structure, create a list of files recursively, generate an unordered list and then create routes dynamically for each MHTML file? I know MHTML files can be embedded with Iframes (although with limited browser support, this is not an issue for me)
The predefined Directory structure is Public/Reports/Dashboard/Exceptions/
Dashboard will contain 1 MHTML file and exceptions (which will be a sort of subnav or child of Dashboard) will contain an undefined amount.
The layout template will be a sort of wrapper.
Anyone who has experience with Rails know the best way of achieving the desired result?
Any help will be sincerely appreciated. I am using Rails 3.0.20 (which doesn't have the Asset pipeline), this will won't be hosted on Heroku (I am aware of no-write permissions)
(Sorry, I'm not super familiar with MHTML files, so I'm going to assume these are just static files that a browser can interpret.)
There is nothing in particular in Rails that provides the behavior that you're referring to. Rails is just a framework to help serve dynamic responses, and the functionality you want is in relation to the filesystem, which Rails mostly abstracts away.
There's a couple options I can think of.
Roll your own
Ruby has file and directory utilities which you could use to read in the contents of a directory in public and render the kind of response you'd like. I would start here:
http://www.ruby-doc.org/core-1.9.3/Dir.html
And play around with ruby's directory globbing to get a file listing.
Use Rack
Rails is built ontop of Rack, a standard webserver interface that most ruby application server implement now. Rack provides some libraries that make serving static assets like a traditional web server a little easier.
Here's a couple of resources to check out:
http://quickleft.com/blog/rack-130-serving-static-files http://edgeguides.rubyonrails.org/rails_on_rack.html