Skip to content

Instantly share code, notes, and snippets.

@raywu
Created March 18, 2012 15:37
Show Gist options
  • Save raywu/2075553 to your computer and use it in GitHub Desktop.
Save raywu/2075553 to your computer and use it in GitHub Desktop.
User model, modified omniauth sessions scraper, and created a smoke-screen search
class User < ActiveRecord::Base
has_many :events
has_many :ratings
has_many :messages
belongs_to :profile
def self.create_with_omniauth(auth)
create! do |user|
user.provider = auth["provider"]
user.uid = auth["uid"]
user.firstname = (auth["info"]["name"]).split.first
user.lastname = (auth["info"]["name"]).split.last
end
end
# This method generates a list of random list of users based on the size of the pool
def self.search
x = User.all.size
b = []
users = User.all.shuffle
x.times do |y|
b << users[rand(y)]
end
b.uniq!
return b
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment