Forum: Ruby on Rails Rendering any file type from an action

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F94645af41332156a1ab1d6e4ff13d8b?d=identicon&s=25 Tushar Ranka (tusharr)
on 2007-07-27 04:51
(Received via mailing list)
I have an app that uses attachment_fu plugin with database at the
backend for attachments. I have no restriction on Mime types that can
be stored. The problem I'm having is related to rendering the files
(allowing users to download the file.

def show
   @stored_file = StoredFile.find(params[:id])
   ##### How do I render the file to the user:
@stored_file.db_file.data
end

I tried respond_to, but that doesn't work for un-registered Mime
Types.

Any help is greatly appreciated
Af9a9013100ddf2dbb0ca13487b60f8b?d=identicon&s=25 Ivor Paul (Guest)
on 2007-07-27 10:39
(Received via mailing list)
You could put a link to the public_filename instead of a show method -
then
rendering download will be a function of the user's browser settings -
in my
case images will show in firefox, pdf's will download etc...

I could be completely wrong about this though :)
This topic is locked and can not be replied to.