CONTENTS OF THIS SITE

OUR OTHER CONTENTS

RECENT BLOG ENTRIES

Twitter4R on Rails

July 26th, 2007 by comment mbbx6spp

Last 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:

  1. Install the Twitter4R v0.2.4 (or above) Ruby Gem: sudo gem install twitter4r
  2. Create a new rails application: rails twitter4rails
  3. 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 Twitter4R

    module 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

  4. 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:

ˆ Back to top