user1544914
user1544914

Reputation: 33

Ruby on rails embed game

I am using rails 3.2.12 version. I want to embed HTML5 game in my static web page (game.html.erb). I am confuse about what will be the src of Iframe tag?

I am using

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

in game.html.erb page

but error occurs

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

I have put game file index.html in same folder as game.html.erb.

what is issue?

Upvotes: 1

Views: 500

Answers (1)

Stewart McKee
Stewart McKee

Reputation: 106

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).

Upvotes: 1

Related Questions