Rails 路线重写

发布于 2024-09-01 13:10:54 字数 1099 浏览 4 评论 0原文

我认为这是一个简单的问题。我正在使用这个有用的 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 如下所示:

http:// /example.com/FlexPaperViewer.swf?ZoomTime=0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf

工作正常。

我的问题是处理这个问题的最佳方法是什么?您能否编写一个重写以 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:

http://example.com/FlexPaperViewer.swf?ZoomTime=0.5&FitPageOnLoad=false&PrintEnabled=false&SwfFile=%2FPaper.swf

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

中性美 2024-09-08 13:10:54

想一想,将 FlexPaperViewer.swf 放在 public/intels 文件夹中怎么样?

所以目录结构将是

<project-directory>/public/intels/FlexPaperViewer.swf

这样做将使链接正确。这样做似乎更容易。
希望它有帮助。

编辑

另一种选择是查看链接是如何生成的,也许在嵌入 FlexPaper 时可以设置一个参数。

我不知道有任何路线修改可以满足您的要求。也许其他人可以帮忙解决这个问题。

Juat a thought, how about placing the FlexPaperViewer.swf inside public/intels folder?

So the directory structure will be

<project-directory>/public/intels/FlexPaperViewer.swf

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文