diff --git a/app/models/contest.rb b/app/models/contest.rb --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -3,6 +3,6 @@ has_and_belongs_to_many :users has_and_belongs_to_many :problems - scope :enabled, :conditions => {:enabled => true} + scope :enabled, -> { where(enabled: true) } end diff --git a/app/models/login.rb b/app/models/login.rb --- a/app/models/login.rb +++ b/app/models/login.rb @@ -1,5 +1,4 @@ class Login < ActiveRecord::Base belongs_to :user - attr_accessible :ip_address, :logged_in_at, :user_id end diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -6,7 +6,7 @@ has_many :testcases, :dependent => :destroy validates_presence_of :name - validates_format_of :name, :with => /^\w+$/ + validates_format_of :name, :with => /\A\w+\z/ validates_presence_of :full_name scope :available, :conditions => {:available => true} diff --git a/app/models/submission_view_log.rb b/app/models/submission_view_log.rb --- a/app/models/submission_view_log.rb +++ b/app/models/submission_view_log.rb @@ -1,3 +1,3 @@ class SubmissionViewLog < ActiveRecord::Base - attr_accessible :submission_id, :user_id + #attr_accessible :submission_id, :user_id end 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 @@ -16,8 +16,7 @@ require 'fileutils' class TestRequest < Task - - set_table_name "test_requests" + self.table_name = "test_requests" belongs_to :user belongs_to :problem diff --git a/app/models/testcase.rb b/app/models/testcase.rb --- a/app/models/testcase.rb +++ b/app/models/testcase.rb @@ -1,4 +1,4 @@ class Testcase < ActiveRecord::Base belongs_to :problem - attr_accessible :group, :input, :num, :score, :sol + #attr_accessible :group, :input, :num, :score, :sol end diff --git a/app/models/user.rb b/app/models/user.rb --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,26 +8,24 @@ has_and_belongs_to_many :roles - has_many :test_requests, :order => "submitted_at DESC" + has_many :test_requests, -> {order(submitted_at: DESC)} - has_many :messages, + has_many :messages, -> { order(created_at: DESC) }, :class_name => "Message", - :foreign_key => "sender_id", - :order => 'created_at DESC' + :foreign_key => "sender_id" - has_many :replied_messages, + has_many :replied_messages, -> { order(created_at: DESC) }, :class_name => "Message", - :foreign_key => "receiver_id", - :order => 'created_at DESC' + :foreign_key => "receiver_id" has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy belongs_to :site belongs_to :country - has_and_belongs_to_many :contests, :uniq => true, :order => 'name' + has_and_belongs_to_many :contests, -> { order(:name); uniq} - scope :activated_users, :conditions => {:activated => true} + scope :activated_users, -> {where activated: true} validates_presence_of :login validates_uniqueness_of :login