Skip to content

Instantly share code, notes, and snippets.

@vestige
Created April 23, 2012 13:44
Show Gist options
  • Save vestige/2471006 to your computer and use it in GitHub Desktop.
Save vestige/2471006 to your computer and use it in GitHub Desktop.
user.rb
class User < ActiveRecord::Base
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.name = auth["info"]["name"]
user.secret = auth["credentials"]["secret"]
end
end
def twitter
unless @twitter_user
user = current_user
provider = user.provider
@twitter_user = Twitter::Client.new(:oauth_token => provider.token, :oauth_token_secret => user.secret) rescue nil
end
@twitter_user
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment