File download from server

363 views
Skip to first unread message

Me

unread,
Aug 15, 2008, 5:00:49 PM8/15/08
to Ruby on Rails: Talk
Is there a way to retrieve a file off the server or hard drive? I
have a program that creates a file and I would like a button to
retrieve the file so the user can save it somewhere. Not ajax right
now.

Lake Denman

unread,
Aug 15, 2008, 5:06:55 PM8/15/08
to rubyonra...@googlegroups.com
# view

<%=button_to "Download File", :action=>'download'%>

# controller

def download
send_file(path_to_file, :disposition => :attachment)
end


send_file documentation
http://railsmanual.org/module/ActionController::Streaming/send_file/1.1.2
--
Posted via http://www.ruby-forum.com/.

Reply all
Reply to author
Forward
0 new messages