Activating the youtube-g gem in Rails 3

by admin on August 15, 2010 · 2 comments

Gems with underscores always seem to mess with me and this one was no exception.  Here’s what goes into the Gemfile to avoid getting NameError/uninitialized constant YouTubeG ruining your day:

gem 'youtube-g', :git => "git://github.com/jasondoucette/youtube-g.git", :require => 'youtube_g'

Note the use of dashes and underscores – the :require directive is what makes this all work.

(Aside: I forked the code from another repository because I want to make some changes – the original documentation suggests that the Client.video_by method can retrieve video information by YouTube URL, but it’s actually the data URL they’re referring to, i.e. http://gdata.youtube.com/feeds/api/videos/UdJ0E7HbTKc and not http://www.youtube.com/watch?v=UdJ0E7HbTKc, which would be a lot more useful for a client app where they can paste in a URL to add the video to their CMS.  If I don’t end up spending another zillion hours fighting configurations, I might even do that.  Check github later…)

As I said, I’ve run into this kind of thing before with underscores and other differences between the gem name and the file name, which in the Rails 2.x world would be fixed with the :lib directive, but now we’ve got Bundler and Gemfiles.

Thanks go out to Andre Arko for his synopsis on Bundler that helped me see the differences.

{ 2 comments… read them below or add one }

Josh January 9, 2011 at 9:30 am

This is great – thanks.

Any idea how I can allow a user to record a website using their webcam and Flash from my site and then use the gem to upload that recorded video to YouTube?

admin January 10, 2011 at 9:52 am

Josh, I haven’t kept up on Flash and YouTube, so maybe this has gotten easier, but in the past this would be two separate problems – getting the video and then submitting it to YouTube.

The recording used to require a media server (Flash Media Server obviously, but I think Wowza would do it) and then once you’ve got the file, the gem’s video_upload method would be the place to start looking.

YouTube does have a new thing called YouTube Direct that might be an easier way to go – the moderation system seems to require Google App Engine, and your integration points will vary depending on your project, but it might be worth a look.

Leave a Comment

Previous post:

Next post: