Created
March 5, 2009 03:20
-
-
Save markbao/74164 to your computer and use it in GitHub Desktop.
This file contains 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
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