arrow_backward Back to blog

Rails Template: Create a Twitter Application in Seconds

TwitterAuth has been out for a little while and has received some great feedback. Dr. Nic released a great template that lets you quickly build a TwitterAuth app for deployment to SliceHost and since I have some plans for a number of Twitter applications I wanted to try my own hand at writing one up.

If you have Rails 2.3, all you need to do is run this:

rails -m http://github.com/mbleigh/rails-templates/raw/master/twitterapp.rb yourappname

Changing yourappname to the directory in which you want to generate your application. The template will then prompt you for three things:

  • What is your application called? Just give it a title for the pretty template generators.
  • OAuth Consumer Key: The consumer key that you register at http://twitter.com/oauth_clients
  • OAuth Consumer Secret

It will also ask you if you want to install missing gems and go ahead and generate your databases and run migrations. Once you’ve responded through the prompts though, you’re good to go! Just switch to your application’s directory and script/server. Your http://localhost:3000 should look like this:

When you click on Login via Twitter you will be taken to the Twitter OAuth approval page.

Twitter will then send you back to your application, and guess what? You’re logged in!

You can now build on top of this without having to worry about the basic authentication stack. If you aren’t familiar with TwitterAuth, it works a lot like RESTful Authentication, so it should be easy to pick up.

Enjoy, and I hope you find it useful!

arrow_backBack

New Project Request