| Author |
Youtube embed
|
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
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
Joined: Nov 03, 2006
Posts: 1300
|
|
#{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
Joined: Apr 27, 2010
Posts: 88
|
|
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
Joined: Nov 03, 2006
Posts: 1300
|
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
Instance variables.
Thanks again
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
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
Joined: Nov 03, 2006
Posts: 1300
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
I removed all but
The browser still doesn't show anyhting
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
ok, show me the controller code, and the routes code.
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
Controller:
Routes:
Migrate Db:
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
|
It displays RoR welcome page.
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
Sorry, i entered just localhost:3000 ><
on entering http://localhost:3000/test, the browser still doesn't display anything
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
|
Ok, what does the server log window show when you start the server?
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
|
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
|
Ok, and when you go to /test what is the output in the server log?
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
Just that.Nothing else
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
Ah, right. What do you get when you say
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
|
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
when i type Video:
when i type Video.all:
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
ok, hm...
what is the path to your view?
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
C:\Sites\vsite\app\views\videos\vidlist.html.erb
C:\Sites\vsite\app\views\layouts\application.html.erb
|
 |
Katrina Owen
Sheriff
Joined: Nov 03, 2006
Posts: 1300
|
|
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
Joined: Apr 27, 2010
Posts: 88
|
|
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
Joined: Nov 03, 2006
Posts: 1300
|
|
Excellent! Good luck
|
 |
santoshkumar savadatti
Ranch Hand
Joined: Apr 27, 2010
Posts: 88
|
|
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
Joined: Nov 03, 2006
Posts: 1300
|
|
|
Good for you for digging into it and finding it!
|
 |
 |
|
|
subject: Youtube embed
|
|
|