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:

