looloobs
looloobs

Reputation: 759

Embed Youtube Video into Rails App

When I put

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

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

<iframe width="560" height="349" src="http://youtu.be/PF9-lstnLvo">
  <html lang="en" dir="ltr">
 </iframe>

HELP!!

Upvotes: 1

Views: 5809

Answers (1)

nyaa
nyaa

Reputation: 1736

Wrong src at iframe, it need to be like:

http://www.youtube.com/embed/PF9-lstnLvo

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

Or method code, which return you this code from @video.link like this:

def code
  self.link.split('/').last if self.link
end

And replace erb:

<iframe width="560" height="349" src="<%= "http://www.youtube.com/embed/"[email protected] %>"></iframe>

Upvotes: 6

Related Questions