File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Youtube embed

 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I came across an Article which allows users to post youtube videos to a RoR site.
However, when i scrolled to the bottom, there's this snippet to display the video:


This is plain html block.
I don't understand how it got the video_id from the database.
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#{video_id}

That evaluates the video_id and embeds it in the string.

If I read the article correctly (skimmed) the video id doesn't come out of a database, it gets parsed from a string/url that the user puts in.
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Katrina.
Is there a way to add youtube videos to a site?
I store video ID (youtube ) in my database.Can i use it to embed the video in the view?
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yepp, if you use the snippet from the article, but pass @video_id to the page, then you can show it with #{@video_id} instead of video_id.
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instance variables.
Thanks again
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam still having problem with it.I'm trying to embed youtube video.

in the videos db table, i have field called "link".This contains the link of the video.

In Controller Videos, there is just empty method def vidlist, since i'm just trying to display single video.
I have vidlist.html.erb:


In routes .rb, i have uncommented the default route matching.
Then, i started server.Entered localhost:3000/Videos/vidlist

The browser doesn't display anything at all.
and there's nothing in the console too when the server is running
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say there is nothing in the controller?

If you comment out the code that tries to display the video, and just say something like "It works" in the view template, do you see "it works"?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed all but
The browser still doesn't show anyhting
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, show me the controller code, and the routes code.

 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Controller:


Routes:


Migrate Db:

 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if you put this in your routes:

match 'test' => 'videos#vidlist'

and you restart the server and go to

http://localhost:3000/test
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It displays RoR welcome page.
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wait, what?
You restarted the server, went to http://localhost:3000/test and it showed you the RoR welcome page?

Please copy/paste the url that is showing you the RoR welcome page.
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, i entered just localhost:3000 ><
on entering http://localhost:3000/test, the browser still doesn't display anything
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, what does the server log window show when you start the server?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, and when you go to /test what is the output in the server log?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just that.Nothing else
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, right. What do you get when you say


 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let's see... Try this:

Start your rails console

rails c

and then type

Video


and then type

Video.all


... what is the output of those?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when i type Video:


when i type Video.all:
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, hm...

what is the path to your view?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
C:\Sites\vsite\app\views\videos\vidlist.html.erb

C:\Sites\vsite\app\views\layouts\application.html.erb
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid I'm stumped.

When I do the following (which seems to be exactly what you've done, except on a mac os x system with ruby 1.9.2)



then go to http://localhost:3000/videos/index

I get the output "hello world" in my browser along with this in the server output:



If you start fresh are you able to get anything in the browser at all?
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm re-installing RoR.
Will give it a fresh try.
It may or may not fix my issue.
But, honestly, thank you very much for taking time.That was very considerate.
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Excellent! Good luck
 
santoshkumar savadatti
Ranch Hand
Posts: 95
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
looks like i found the problem.
It's mysql.mysql.dll is not compatible with win 7.There are a couple of ways to fix that issue and i used them.When installed using Ruby installer, it wont even allow to create new project.
Then, i installed with railsinstaller, i can create a project and work fine.Only, it blows up at run time.One solution was to stick with sqlite.It doesn't cause any problems.
centOS, here i come.
 
Katrina Owen
Sheriff
Pie
Posts: 1367
18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good for you for digging into it and finding it!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic