Skip to content

Migrating to ID based Accounts

sishen edited this page Sep 13, 2010 · 2 revisions

Version 0.1.20 of TwitterAuth uses the Twitter ID instead of the screen name to key and lookup Twitter users. This breaks compatibility because twitter_id is now a required attribute but does not exist in prior tables. To remedy this, you will need to take the following steps:

First, create a migration to add the string attribute twitter_id and run the migration before you upgrade TwitterAuth.

Next, in script/console, run something like this:

User.all.each do |user|
  user.twitter_id = user.twitter.get('/account/verify_credentials')['id']
  user.save
end

This will populate the twitter_id attribute with each of your users’ correct Twitter IDs. Now you can upgrade TwitterAuth and you should be good to go!

Clone this wiki locally