Created
March 18, 2012 15:37
-
-
Save raywu/2075553 to your computer and use it in GitHub Desktop.
User model, modified omniauth sessions scraper, and created a smoke-screen search
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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