我需要下載二進制數據。我已嘗試send_data
方法,但它節省了整個 .html頁面。 我無法訪問控制器中的send_data
方法,所以我在應用程序控制器中聲明瞭helper_method。導軌。如何通過send_data下載數據?
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :save_data
def save_data
send_data('Hello, pretty world :(', :type => 'text/plain', :disposition => 'attachment', :filename => 'hello.txt')
end
end
我做錯了什麼?謝謝。
你在哪裏調用'save_data'? –
@IdanArye在我的一個觀點。說網頁/ home.erb – user2422869