From 40df91eb5dab9f7c6e7038f125bf20b27e96059b Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Sun, 29 Sep 2019 09:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BA=AB=E4=BB=BD=E8=AF=81=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E5=8C=B9=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/games_controller.rb | 4 ++-- app/models/user.rb | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/controllers/games_controller.rb b/app/controllers/games_controller.rb index 98894788f..8a3999410 100644 --- a/app/controllers/games_controller.rb +++ b/app/controllers/games_controller.rb @@ -657,7 +657,7 @@ class GamesController < ApplicationController # 高性能取上一关、下一关 prev_game = @game.prev_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) - next_game = @game.next_of_current_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed + next_game = @game.next_game(@shixun.id, @game.myshixun_id, game_challenge.position) if had_passed next_game.update_column(:status, 0) if next_game.present? && next_game.status == 3 # 高性能取上一关、下一关 @@ -671,7 +671,7 @@ class GamesController < ApplicationController choose_correct_num: choose_correct_num, test_sets: test_sets, prev_game: prev_game, - next_game: next_game} + next_game: next_game&.identifier} rescue Exception => e uid_logger("choose build failed #{e.message}") @result = [status: -1, contents: "#{e.message}"] diff --git a/app/models/user.rb b/app/models/user.rb index 70cd54c92..69b48a8cb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -20,6 +20,8 @@ class User < ApplicationRecord VALID_EMAIL_REGEX = /^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/i VALID_PHONE_REGEX = /^1\d{10}$/ + # 身份证 + VALID_NUMBER_REGEX = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/ LOGIN_LENGTH_LIMIT = 30 MAIL_LENGTH_LMIT = 60 @@ -162,6 +164,7 @@ class User < ApplicationRecord # validates_format_of :mail, with: VALID_EMAIL_REGEX, multiline: true # validates_format_of :phone, with: VALID_PHONE_REGEX, multiline: true validate :validate_password_length + validate :ID_number, with: VALID_NUMBER_REGE # validates :nickname, presence: true, length: { maximum: 10 } # validates :lastname, presence: true