# HG changeset patch # User Nattee Niparnan # Date 2014-08-21 09:12:34 # Node ID 6d2339b98facaf7242b9e407e08336de3ef56c64 # Parent d02b70f6c47455d79c681c1929af5300c56c18aa update errors.add_to_base("x") to Rails 3 errors.add(:base,"x") diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -69,7 +69,7 @@ @submission.submitted_at = Time.new.gmtime if GraderConfiguration.time_limit_mode? and user.contest_finished? - @submission.errors.add_to_base "The contest is over." + @submission.errors.add(:base,"The contest is over.") prepare_list_information render :action => 'list' and return end diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -26,7 +26,7 @@ if GraderConfiguration.time_limit_mode? if @user.contest_finished? - @submitted_test_request.errors.add_to_base('Contest is over.') + @submitted_test_request.errors.add(:base,'Contest is over.') prepare_index_information render :action => 'index' and return end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -62,7 +62,7 @@ render :action => 'email_error', :layout => 'empty' end else - @user.errors.add_to_base("Email cannot be blank") if @user.email=='' + @user.errors.add(:base,"Email cannot be blank") if @user.email=='' render :action => 'new', :layout => 'empty' end end diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -44,7 +44,7 @@ import_params[:time_limit], import_params[:memory_limit], import_to_db) - problem.errors.add_to_base('Import error.') + problem.errors.add(:base,'Import error.') end return problem, importer.log_msg @@ -77,17 +77,17 @@ DEFAULT_MEMORY_LIMIT) if time_limit<=0 or time_limit >60 - problem.errors.add_to_base('Time limit out of range.') + problem.errors.add(:base,'Time limit out of range.') end if memory_limit==0 and params[:memory_limit]!='0' - problem.errors.add_to_base('Memory limit format errors.') + problem.errors.add(:base,'Memory limit format errors.') elsif memory_limit<=0 or memory_limit >512 - problem.errors.add_to_base('Memory limit out of range.') + problem.errors.add(:base,'Memory limit out of range.') end if params[:file]==nil or params[:file]=='' - problem.errors.add_to_base('No testdata file.') + problem.errors.add(:base,'No testdata file.') end file = params[:file] diff --git a/app/models/test_request.rb b/app/models/test_request.rb --- a/app/models/test_request.rb +++ b/app/models/test_request.rb @@ -70,12 +70,12 @@ # checks if the user submits any input file if params[:input_file]==nil or params[:input_file]=="" - test_request.errors.add_to_base("No input submitted.") + test_request.errors.add(:base,"No input submitted.") test_request.input_file_name = nil else test_request.input_file_name = save_input_file(params[:input_file], user, problem) if test_request.input_file_name == nil - test_request.errors.add_to_base("No input submitted.") + test_request.errors.adds(:base,"No input submitted.") end if params[:additional_file]!=nil and params[:additional_file]!="" save_additional_file(params[:additional_file], diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -298,7 +298,7 @@ def uniqueness_of_email_from_activated_users user = User.activated_users.find_by_email(self.email) if user and (user.login != self.login) - self.errors.add_to_base("Email has already been taken") + self.errors.add(:base,"Email has already been taken") end end @@ -309,7 +309,7 @@ :order => 'created_at DESC') if open_user and open_user.created_at and (open_user.created_at > Time.now.gmtime - 5.minutes) - self.errors.add_to_base("There are already unactivated registrations with this e-mail address (please wait for 5 minutes)") + self.errors.add(:base,"There are already unactivated registrations with this e-mail address (please wait for 5 minutes)") end end