Twitter4R on Rails
July 26th, 2007 byLast night Twitter4R version 0.2.4 was released with a fix that makes using Twitter4R in Rails much easier.
So let’s quickly kick the tires to see how this all works:
- Install the Twitter4R v0.2.4 (or above) Ruby Gem: sudo gem install twitter4r
- Create a new rails application: rails twitter4rails
- After setting up your config/database.yml to your personal tastes and tweaking the Rails configuration settings in environment.rb, scroll to the bottom of environment.rb and add the following:
gem(‘twitter4r’, ‘>=0.2.4′)
require(‘twitter’) # loads core library
require(‘twitter/console’) # loads a helper method we will use
require(‘twitter/rails’) # added Rails extensions for Twitter4Rmodule YourAppNamespace
ENV["RAILS_ENV"] ||= “test” # assume test environment if no RAILS_ENV set.
ClientContext = Twitter::Client.from_config(“#{RAILS_ROOT}/config/twitter.yml”, ENV["RAILS_ENV"])
end - Now in your controllers you can access YourAppNamespace::ClientContext object as you need to or any other part of the Twitter4R API.
If you still want more, feel free to check out the following links:

July 28th, 2007 at 4:00 pm
Cool beans — would like to see the high res video, although this one got the point across for me.
July 28th, 2007 at 5:22 pm
Thanks!
July 28th, 2007 at 8:31 pm
Actually I realized that YouTube automatically downgrades the resolution of videos quite drastically during the upload process. Google Video is also quite low res (though slightly better). Anyone know a better venue for higher res videos?
July 29th, 2007 at 11:01 am
Unfortunately, neither of the free vid hosts serve good quality vids. The options are to host the vid on your server and distribute it via iTunes or as a downloadable vid file.
July 30th, 2007 at 6:05 am
Susan, we can find a place to host it either on one of my servers or on one of the devChix servers just ping me on the list and we will find a place to put it.
Desi
July 30th, 2007 at 7:42 am
Desi: Thanks, but to be honest I have tons of bandwidth sitting in one of my plans that needs to be used, plus I doubt this screencast will be in overly high demand anyway.
Carmelyne: Thanks for the information on iTunes, I’ll look into it. I’ll post relevant links here later today with the downloadable file URL and/or iTunes URL for the higher res video.
August 1st, 2007 at 7:19 pm
I kept forgetting to post the download URL:
http://twitter4r.rubyforge.org/screencasts/twitter4r_on_rails.mp4
Unfortunately I didn’t have time to find out where to configure an iTunes podcast for it as a web front-end didn’t seem easy to find.