Skip to content

Instantly share code, notes, and snippets.

@markbao
Created March 5, 2009 03:20
Show Gist options
  • Save markbao/74164 to your computer and use it in GitHub Desktop.
Save markbao/74164 to your computer and use it in GitHub Desktop.
if request.post?
firstname = params[:firstname]
lastname = params[:lastname]
prefix = params[:prefix]
email = params[:email]
subdomain = params[:subdomain]
o = [('a'..'z'),('0'..'9')].map{|i| i.to_a}.flatten # map of a-z0-9
password = (0..5).map{ o[rand(o.length)] }.join # create random password from map
@account = Account.find_by_subdomain(current_subdomain)
user = User.create do |u|
u.firstname = firstname
u.lastname = lastname
u.usertype = 0
u.account_id = @account.id
u.email = email
u.password = password
u.prefix = prefix
u.contact = ''
u.subdomain = subdomain
end
if user.save
redirect_to "/admin/teacher/" + user.id
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment