[英]Rails link_to :format => :xlsx not generating link to .xlsx path
如果我點擊這個網址: http://localhost:3000/reports/action.xlsx
它會顯示一個生成的 xlsx 文件。
如果我有這樣的link_to
:
<%= link_to 'Export to Excel', reports_affirmative_action_path, :format => :xlsx %>
它會生成一個指向此頁面的鏈接: http://localhost:3000/reports/action
為什么我的帶有:format => :xlsx
link_to 沒有鏈接到正確的路徑?
您的link_to
和path
略有link_to
。 你要
<%= link_to('Export to Excel', reports_affirmative_action_path(format: :xlsx)) %>
其中格式是path
助手的參數,而不是link_to
。
為我工作
<%= link_to('導出到 Excel', reports_affirmative_action_path(:format => :xls)) %>
使用 :xls 而不是 :xlsx
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.