30 Jul 2009

Now You Can Have Better Youtube Integration with Ruby on Rails

rails-tip posted by vibha

I recently wanted to upload, edit, update and delete a video directly on youtube from my rails application. This can be achieved by YouTube Data API that allows application to perform functions normally executed on youtube.

Step 1 : Demystifying Authentication with Google AuthSub

Google provides an authentication service to those web applications that need to access services protected by a user’s Google account. I chose Google’s ‘AuthSub’ scheme for this. This also provides a high level of security to web application.
The AuthSub interface provides several methods for acquiring and managing authorization tokens. Once a web application has received a token, it can request access to a Google service.

To obtain an authentication token, submit an HTTP POST request to the following URL:


https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Fwww.example.com%2Fupload.html&scope=http%3A%2F%2Fgdata.youtube.com&session=0&secure=0

Setting session parameter to 1 indicates that the single-use token can be exchanged for a session token.
AuthSubSessionToken is a method that allows the web application to exchange a single-use token for a session token. I used a gem ‘gdata’ to convert the token into a session token.

client = GData::Client::DocList.new
client.authsub_token = params[:token]
session[:token] = client.auth_handler.upgrade()

Session token allows the application to make unlimited calls to the Google service. When using session tokens, your application should store the session token for each user rather than requesting a new one each time it needs to access a Google service. For other token management options, see Working With AuthSub.

Step 2 : Getting the Youtube Developer Key

A developer key is required that identifies the YouTube developer that is submitting an API request. A client ID identifies your application for logging and debugging purposes. Please visit here to obtain a developer key and client ID.

Step 3 : Improving the Youtube Model Plugin

“youtube-model” is a plugin  that provides youtube video uploading functionality. That was a good start.
I forked the plugin and updated it with few methods to get the rest of  the functionality done. Each method is explained here.
1. uploaded_by_user
A method uploaded_by was provided in the plugin to retrieve all the videos of the user but it receives username as a parameter. So I added a method uploaded_by_user that receives the session token and solves our purpose.

YouTube.uploaded_by_user(session[:token])

2. update_video
The video can be updated by using this method passing video id, session token and params hash as parameters.

YouTube.update_video(params[:id], session[:token], params[:you_tube_entry])

3. delete_video
The video can also be deleted if uploaded at the user’s youtube account by passing video id and token as a parameter.

YouTube.delete_video(params[:id], session[:token])

4. video_status
This method helps finding out the status of uploaded video.

s = YouTube.video_status(session[:token], params[:id])
@status = s.control.state.name

The changes to the plugin have been merged in the master and you can download everything here. I will really appreciate your feedback and suggestions to make this plugin better.

Vibha Chadha is working with Vinsol as a rails developer. When she is not writing code, she likes to read “geek” books and listen  to some “good” music.

24 Jul 2009

Git Work Flow For Ruby on Rails Developers

Git, rails, web development posted by sid

Cross posted from darthsid

This is my very first blog post and so I though it should be about a tool that is indispensable for me – Git. I started using git about 10 months ago and looking back I can’t imagine how I managed to get work done without it. The purpose of this post however is not to sing git’s praises, there are lots of good articles on the web that do so much better than I ever could. Instead, I wish to share the work-flow I use on my projects. I developed this work-flow by trial and error over the months and is currently the most efficient and productive approach I can think of. If any experienced git users happen to stumble upon this post, please do provide suggestions/alternatives to help me improve my process.

The project I am currently working on requires me to maintain two parallel deployment branches. One is a “production branch” which is deployed on the live server and the other is a “development branch” which is deployed on a staging server. All enhancements and feature additions are done in the “development branch” and the only changes made in the “production branch” are production bug fixes that need urgent attention. Once the “development branch” is deemed stable it is merged into “production branch” and deployed.
Read more

14 Jul 2009

New Ruby on Rails Plugin- Launching Soon has launched

plugin, rails plugins, ruby on rails posted by manik

Launching Soon” is a new plugin that VinSol has developed.

Working on client projects, we saw a pattern – the client owns a domain, which is either parked or has a blog running on it, and then they commission us to build an application. While the application is being developed, they want us to setup a landing page on the server, with a couple of links – to the blog etc. and want to capture email addresses of people who are interested in the service that the application would offer.

We actually found a few ready to use options for this. This php based paid script was one and there is also a  free launching soon module in PHP/Jquery.

However, we did not find anything for Rails so Satish set out to write a plugin for it. Then we thought it would be good to integrate it with Campaign Monitor , since most of our clients use this service for running their email campaigns.  And subsequently Satish extended it to add Mail Chimp integration also.

Give it a spin and send us your feedback via the LightHouse project.

05 May 2009

RailsConf Day 1 – Links to slides and blog posts

railsconf posted by kapil
  • This is the official link for all the presentation files, so whenever you are looking for PPTs , this is the first place

http://en.oreilly.com/rails2009/public/schedule/proceedings

Please add any other userful links which I missed through comments. Looking forward for day 2. We are wearing black t -shirts with Vinsol printed in red.

03 May 2009

Why RailsConf at Las Vegas is a great opportunity for the community ?

railsconf posted by kapil

Just few hours before start of rails conf 09 ,  people have started assembling in Las Vegas.  Attendees reaching early are already finding themselves busy , I was following twitter stream of #railsconf  and  found some interesting tweets which you usually don’t find before a major tech conference :

: more than doubled my money playing blackjack tonight. #railsconf

:On my 27th hour and drunk with in Vegas! #railsconf

:any other old fights we can drudge up? Let’s turn RailsConf into a 1,000+ person free-for-all brawl.

:really excited for @railsconf – had 4 people tell me not to lose too much money. i wasn’t aware i had a gambling problem. (denial)

And , people opposing the idea of rails conf in LV will be very happy looking at these tweets but they miss a very major point which objo puts it beautifully and why our team at Vinsol is attending railsconf :

objoBut thinking about the event and all the friends I get to see and I’m stoked. Location really does not matter. Some of the brightest minds I know get together once a year in the summer. What gets discussed months ahead of time? #railsconf

As a part of rails community, I would appeal all of the people coming to railsconf09 to work hard and play harder . It’s an opportunity for all of us to show that we are one of the best  community in the world with respect for everyone and some sense of humour.  Looking forward to meet all of you
Next Page »« Previous Page