gpt4 book ai didi

ruby-on-rails-4 - 无法在Rails4中将.xls注册为自定义MIME类型

转载 作者:行者123 更新时间:2023-12-04 17:09:28 24 4
gpt4 key购买 nike

我已经更新了 config/initializers/mime_types.rb 并重新启动了服务器。

Mime::Type.register "application/vnd.sealed-xls", :xls

我的 Controller 如下所示:
respond_to do |format|
format.xls { send_file(file_name, filename: "dagsrapport.xls") }
format.html
end

这是我在 /sheet.xls上执行GET时遇到的错误
To respond to a custom format, register it as a MIME type first: 
http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads. If you meant to
respond to a variant like :tablet or :phone, not a custom format, be sure to nest your variant
response within a format response: format.html { |html| html.tablet { ... } }

关于我所缺少的任何提示吗?根据文档,我看不到我在做什么错: http://guides.rubyonrails.org/action_controller_overview.html#restful-downloads

最佳答案

我所做的所有将xls注册为Mime类型的操作-刚添加到 config/initializers/mime_types.rb Mime::Type.register "application/xls", :xls并重新启动服务器。希望能对您有所帮助。

关于ruby-on-rails-4 - 无法在Rails4中将.xls注册为自定义MIME类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25739039/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com