Skip to content

Instantly share code, notes, and snippets.

@kracekumar
Created March 11, 2011 19:06
Show Gist options
  • Save kracekumar/866387 to your computer and use it in GitHub Desktop.
Save kracekumar/866387 to your computer and use it in GitHub Desktop.
def admission2
@student = Student.find params[:id], :include => [:guardians]
@guardian = Guardian.new params[:guardian]
@g_u=GuardianUser.new()
@g_u[:guardian_id]=@guardian[:id]
@g_u[:email]=@guardian[:email]
@g_u[:ward_id]=@guardian[:ward_id]
randstr=""
chars=("0".."9").to_a + ("a".."z").to_a + ("A".."Z").to_a
8.times { randstr << chars[rand(chars.size -1)] }
@g_u[:salt]=randstr
@g_u[:hashed_password]=Digest::SHA1.hexdigest(@g_u[:salt]+@g_u[:email])
if request.post? and @guardian.save and @g_u.save
redirect_to :controller => "student", :action => "admission2", :id => @student.id
end
end
error
/var/www/admin/app/controllers/student_controller.rb:93:in `size'
/var/www/admin/app/controllers/student_controller.rb:93:in `admission2'
/var/www/admin/app/controllers/student_controller.rb:93:in `times'
/var/www/admin/app/controllers/student_controller.rb:93:in `admission2'
@Hates
Copy link

Hates commented Mar 11, 2011

rand(chars.size - 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment