如何拥有params和url

编程入门 行业动态 更新时间:2024-10-16 16:41:15
如何拥有params和url_for的URL?(How do I have a URL with params and a url_for?)

我只是想为我的网站设置excel下载选项。 我想做的就是:

<%= link_to 'Export', export_to_excel_path(:param => @item.id), url_for(:format => 'xls') %>

我想给我的用户一个导出到excel的链接,附加的参数。 我收到以下错误:

undefined method `stringify_keys' for "/controller/show.xls":String

我需要使用url_for,因为在export_to_excel中,我有一个

respond_to

为了响应.xls MIME类型文件。 我正在使用to_xls gem,一切正常,但我无法弄清楚这个链接。

I'm just trying to setup excel downloading option for my site. All I want to do is:

<%= link_to 'Export', export_to_excel_path(:param => @item.id), url_for(:format => 'xls') %>

I want to give my user a link to export to excel, with the additional param. I get the following error:

undefined method `stringify_keys' for "/controller/show.xls":String

I need to use url_for because in export_to_excel, I have a

respond_to

in order to respond with a .xls MIME type file. I am using the to_xls gem, and everything works fine except that I'm not able to figure out this link.

最满意答案

归功于jdoe:

<%= link_to 'Export', export_to_excel_path(:param => @item.id, :format => 'xls') %>

All credit to jdoe:

<%= link_to 'Export', export_to_excel_path(:param => @item.id, :format => 'xls') %>

更多推荐

本文发布于:2023-08-05 00:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423386.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:params   url

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!