Created
August 23, 2011 15:20
-
-
Save joecannatti/1165406 to your computer and use it in GitHub Desktop.
creates a user who needs an invite
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 MakeUserToInvite | |
def self.make(community_id=55,first_name=nil,last_name=nil,email=nil) | |
p = Person.new | |
p.first_name = first_name || random_string | |
p.last_name = last_name || random_string | |
e = EmailAddress.create(:person => p, | |
:email_address => (email || "#{random_string}@aoeuaoue.com"), | |
:confirmed_status => "confirmed", | |
:is_primary => true) | |
e.save | |
p.preloaded = true | |
p.save | |
c = Channel.find(55) | |
c.add_member p | |
c.add_preloaded_person! p | |
p.clear_advanced_caching! | |
end | |
def self.random_string | |
(0...8).map{65.+(rand(25)).chr}.join | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment