Rails 如何让 RAILS 支持中文路径?

suffering · March 12, 2012 · Last by Rei replied at March 12, 2012 · 4325 hits

使用 paperclip 上传文件。 客户需要可以上传中文的文件。但是,在 rails 里,似乎<%= link_to “download", “你好.rar" %>这样的链接会找不到文件。报的是 routes 错误。 试过 URI.encode 的方案,不行。大家平时是怎么做的?

若非是send_file?

link_to 自然可以 既然报 route 错误 就是找不到这个 rar 文件 建议楼主贴出来报错信息+paperclip 配置

routes error 在 routes 解决,路由后面接上 :constraints => { :id => /.+/ }, :id 换成你要的参数

注意不要留下 '../../../etc/passwd' 这样的漏洞,总归要对文件名做一些处理

You need to Sign in before reply, if you don't have an account, please Sign up first.