我想在我的展示頁面上放置下載功能,但是頁面上沒有標誌,當頁面打開時不自動下載,只有圖像下載不起作用。 表演形式 -如何在ROR的展示頁面上放置下載選項
<tr>
<th><strong>Download Document</strong></th>
<td><%= link_to '',download_screenshot_path(id: issue_request.id),class: 'btn btn-xs fa fa-download' %></td>
<th><strong>Download Image</strong></th>
<td><%= link_to '',download_screenshot_image_path(id: issue_request.id),class: 'btn btn-xs fa fa-picture-o' %></td>
</tr>
控制方法 -
def show
@issue_request = IssueRequest.find(params[:id])
send_file @issue_request.document1.path,
filename: @issue_request.document1_file_name,
type: @issue_request.document1_content_type,
disposition: 'attachment'
@issue_request = IssueRequest.find(params[:id])
send_file @issue_request.document2.path,
filename: @issue_request.document2_file_name,
type: @issue_request.document2_content_type,
disposition: 'attachment'
end
**但標誌不在頁面上** - 您期望在頁面上顯示什麼標誌?你沒有提供任何東西給'link_to'來命名你的下載鏈接。 – dp7
我的意思是下載按鈕沒有進入頁面。 –
爲您的鏈接命名:'<%= link_to'下載',download_screenshot_path(id:issue_request.id),class:'btn btn -xs fa fa-download'%>' – dp7