Ransack Search Results - to_xls?

自闭症网瘾萝莉.ら 提交于 2019-12-03 17:20:18

I know this is such a hack, after spending many hours of not getting it, I used it anyway.

<a href="/expenses.xls?<%= request.fullpath.split("?")[1]  %>">make xls</a>

so basically it takes the searchpath after the ?, then adds it to your model.xls output path and then it works. I hate it myself, there must be a better way, but deadlines.

There was a good link here.

Musili

Ronin gave a simple solution to this related question, but with CSV instead of XLS . In my case, using Ronin's answer, I just rewrote the link to work with XLS as shown below

<%= link_to "Download Excel", reports_path(params.merge(format: "xls")) %>
%= link_to "Download Excel", yours_controller_path(params.merge(format: "xls")) %>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!