1

我正在使用 rails 3.2.12 版本。我想在我的静态网页 (game.html.erb) 中嵌入 HTML5 游戏。我对 iframe 标记的 src 会是什么感到困惑?

我在用

<pre> 
iframe src="index.html" height="460" width="500"
</pre> 

game.html.erb页面中

但发生错误

NO ROUTE MATCHES GET "/static_pages/index.html"

我已将游戏文件index.html放在与game.html.erb相同的文件夹中。

什么是问题?

4

1 回答 1

1

If the html is static then just move the html file into the '/public' folder of your rails app and change the src for the iframe to be "/index.html"

If you don't want to put it into the public folder, you'll need to either add an action to the controller that your game.html.erb is rendered from or create a separate controller for the static html.

Based on what your question states though, I would put it into the public folder as it is just static html and wouldn't require a controller.

The problem with the setup you have is that your index.html file is just a static file, where the view folder that contains game.html.erb relates to a controller and is rendered from an action in the controller. Static files don't get rendered from that folder. The public folder contains static files and folders that you want on the root of your site (except for javascript, images and css which go in the asset pipeline).

于 2013-03-15T15:24:56.810 回答