### Check for unique username and generate a better one if needed. ## Refined to now only hit the database once per call. def unique_username? ##p "Debug: guess at top of predicate: #{@guess}" ## Cache the usernames of everyone with the same last name @taken = MoocashOrder.find_all_by_student_lname(self.student_lname).collect do |moo| moo.username end ##p "Debug: taken list before while: #{@taken}" ##implied for @inc 0 to length of fname @inc = 1 ##prime @guess with the one we know doesn't work, so we enter the while ... @guess = self.username ##p "Debug: guess before while: #{@guess}" ## Keep trying guesses until we get a non match while @taken.include?(@guess) ## use more of first name: @guess = "#{self.student_fname.downcase[0,@inc+1]}#{self.student_lname.downcase}" ##p "Debug: first guess in while: #{@guess}" ## shortcut out if we find a non-matching username break if not @taken.include?(@guess) ## and then try appending numbers, ugh @guess = "#{@guess}#{@inc}" ##p "Debug: second guess in while: #{@guess}" ## shortcut out if we find a non-matching username break if not @taken.include?(@guess) ##sanity break: if @inc > 29 p "Incremented to 29, giving up!" end ## and increment imaginary for loop @inc = @inc + 1 end ##p "Debug: guess after while: #{@guess}" self.username = @guess end
Unique Username?
-
D2 AJAX working, but Highlighting throws RJS type error null value
And Safari then spews a dialog full of this: Element.update("cart", .. LJ can't handle this, please link through to forum.. ); Interestingly, as…
-
Moodle sql injection works, milestone complete.
## Since the Moodle external enrollment database code doesn't work, ## we fall back to manual SQL injection for MySQL, eg: ## +insert into…
-
It's thursday and the code mostly works
Code works manually but not in the script. Anyone receiving multiple new account emails can rest assured that this is a good sign ;)…
- Post a new comment
- 0 comments
- Post a new comment
- 0 comments