Rails 路线重写
我认为这是一个简单的问题。我正在使用这个有用的 Flash 文档阅读器,名为 FlexPaper。我已将其嵌入到我的显示页面之一中。但是,当我单击工具栏上的链接以在新浏览器中显示文档时,它指向以下链接:
http://example.com/intel/FlexPaperViewer.swf?ZoomTime =0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf
不起作用,我收到以下错误:
IntelsController#show 中的 ActiveRecord::RecordNotFound
找不到 ID=FlexPaperViewer 的 Intel
,但如果我从路径中删除“intel”,则 url 如下所示:
工作正常。
我的问题是处理这个问题的最佳方法是什么?您能否编写一个重写以 intels/FlexPaperViewer.swf
开头的 url 的路由并删除 intels 前缀?那会是什么样子?
有更好的选择吗?
I think this is an easy question. I am using this useful Flash Document Reader called FlexPaper. I have it embedded in one of my Show pages. But when I click the a link on their tool bar to show the document in a new browser, it points to the following link:
http://example.com/intels/FlexPaperViewer.swf?ZoomTime=0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf
which doesn't work, I get the following error:
ActiveRecord::RecordNotFound in IntelsController#show
Couldn't find Intel with ID=FlexPaperViewer
but if I remove the "intels" from the path so the url looks like:
It works fine.
My question is what is the best way to handle this? Can you write a route that rewrites a url that starts with intels/FlexPaperViewer.swf
and remove the intels prefix? What would that look like?
Is there a better option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
想一想,将 FlexPaperViewer.swf 放在 public/intels 文件夹中怎么样?
所以目录结构将是
这样做将使链接正确。这样做似乎更容易。
希望它有帮助。
编辑
另一种选择是查看链接是如何生成的,也许在嵌入 FlexPaper 时可以设置一个参数。
我不知道有任何路线修改可以满足您的要求。也许其他人可以帮忙解决这个问题。
Juat a thought, how about placing the FlexPaperViewer.swf inside public/intels folder?
So the directory structure will be
Doing this will make the link correct. It seems to be easier to do it this way.
Hopefully it helps.
EDIT
Another alternative will be to see how the link was generated, maybe there is a parameter that you can set when you embed the FlexPaper.
I am not aware of any route modification that can do what you want. Maybe someone else can help on this.