내 컴퓨터에 다운로드 링크를 설정하려는 파일의 경로가 있습니다. 내 모델에서경로에서 파일을 다운로드하는 링크
: 여기에 내가 노력하고있어입니다
class Exam < ActiveRecord::Base
attr_accessible :data, :full_path
has_attached_file :image,
:path => :full_path
end
내 컨트롤러는 다음과 같습니다
def download
@exam = Exam.find(params[:id])
send_file @exam.image.path, :x_sendfile => true
end
그리고 내보기 : 이제
<%= link_to "Download", download_exam_path(@exam) %>
I 다운로드를 클릭하십시오이 오류가 발생합니다 : can't convert nil into String
나는 사실을 알고 :full_path
에 내 파일의 올바른 경로가 포함되어 있습니다. 이 문제를 어떻게 해결할 수 있습니까?
전체 오류 : @exam
이보기에 nil
처럼
TypeError in ExamsController#download
can't convert nil into String
Rails.root: /Users/Ryan45/Programming/rails_projects/oldV_rails_project
Application Trace | Framework Trace | Full Trace
app/controllers/exams_controller.rb:83:in `download'
Request
Parameters:
{"id"=>"392"}
Show session dump
Show env dump
Response
Headers:
None
'exams_controller.rb'의'send_file @ exam.image.path, : x_sendfile => true' 라인 83입니까? –
예, 실제로입니다. – DashControl
그냥 '종이 클립'을 사용하고 있습니까? –