Getting Admob to Work with Rails3/Ruby19

When I tried to add Admob to my mobile site a few days ago, I discovered that Google/Admob’s ruby gem only works with Ruby 1.8.7 and Rails 2. Considering that Rails3 is was released earlier this year, it was surprising that the gem had not been updated. Anyways, as its open-source, I was able to get the code from rubyforge and make the required changes.

The new gem is called ‘admod19′ and can be installed easily by typing gem install admob19. If you would like to get the source, its on github at

For those that wand the technical details of the changes that I made, here is a list of what was updated.

  1. how session ID was accessed. session.session_id was changed to session[:session_id]
  2. updated MD5 calls to use new module name. MD5 is now Digest::MD5
  3. strip off any rack or rails headers in the request that is sent to Admob

Final note, follow the instruction in the gem’s README.txt file rather than what’s up on Admob’s site and you should be up and running quickly. Oh, and Admob is not returning ads, it’s possible they have no inventory. Easiest way to test that is to add an in-house add and have Admob use that whenever they don’t have an ad to server.


Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>