Ruby-on-rails – Embed Youtube Video into Rails App


When I put

<iframe width="560" height="349" src="<%= %>"></iframe>

Everything shows up fine. But the actual video won't play.. what am I doing wrong?

<iframe width="560" height="349" src="">
  <html lang="en" dir="ltr">


Best Solution

Wrong src at iframe, it need to be like:

You need to add code:string to you Video model.

Or method code, which return you this code from like this:

def code'/').last if

And replace erb:

<iframe width="560" height="349" src="<%= ""+@video.code %>"></iframe>