index.html.erbLàm thế nào để có được nội dung của tập tin tạm thời thông qua một hình thức
= form_for :file_upload, :html => {:multipart => true} do |f|
= f.label :uploaded_file, 'Upload your file.'
= f.file_field :uploaded_file
= f.submit "Load new dictionary"
Mẫu
def file_upload
file = Tempfile.new(params[:uploaded_file])
begin
@contents = file
ensure
file.close
file.unlink # deletes the temp file
end
end
Index
def index
@contents
end
Nhưng không có gì là nhận in của tôi trang sau khi tôi tải lên một tệp = @contents
Làm cách nào để gửi nội dung trở lại chỉ mục – ahmet