Is there a recipe for downloading files in Rails? I’m kind of new to Rails (and Ruby) and not finding much help on this subject on the net.
In my app, I have a page with a list of files (mostly pdf but there are other types like doc, xls, etc.). The list of files is generated by a statement in the controller index method by reading the content of a specific directory (no model):
@files = Dir.glob(path_to_files)
In the @index.html.erb@, a loop lists the files. Next to each filename, I want to have a download link, such that, when the user clicks it, it invokes the @download@ method in the controller:
send_file = @current_file.to_s
So far, I haven’t been successful implementing this scheme so any help or pointers would be greatly appreciated.