Skip to content

Instantly share code, notes, and snippets.

@joecannatti
Created August 23, 2011 15:20
Show Gist options
  • Save joecannatti/1165406 to your computer and use it in GitHub Desktop.
Save joecannatti/1165406 to your computer and use it in GitHub Desktop.
creates a user who needs an invite
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