Description:
update models to satisfy rails 4
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r618:45e8321629ae - - 7 files changed: 12 inserted, 16 deleted

@@ -3,6 +3,6
3 has_and_belongs_to_many :users
3 has_and_belongs_to_many :users
4 has_and_belongs_to_many :problems
4 has_and_belongs_to_many :problems
5
5
6 - scope :enabled, :conditions => {:enabled => true}
6 + scope :enabled, -> { where(enabled: true) }
7
7
8 end
8 end
@@ -1,5 +1,4
1 class Login < ActiveRecord::Base
1 class Login < ActiveRecord::Base
2 belongs_to :user
2 belongs_to :user
3
3
4 - attr_accessible :ip_address, :logged_in_at, :user_id
5 end
4 end
@@ -6,7 +6,7
6 has_many :testcases, :dependent => :destroy
6 has_many :testcases, :dependent => :destroy
7
7
8 validates_presence_of :name
8 validates_presence_of :name
9 - validates_format_of :name, :with => /^\w+$/
9 + validates_format_of :name, :with => /\A\w+\z/
10 validates_presence_of :full_name
10 validates_presence_of :full_name
11
11
12 scope :available, :conditions => {:available => true}
12 scope :available, :conditions => {:available => true}
@@ -1,3 +1,3
1 class SubmissionViewLog < ActiveRecord::Base
1 class SubmissionViewLog < ActiveRecord::Base
2 - attr_accessible :submission_id, :user_id
2 + #attr_accessible :submission_id, :user_id
3 end
3 end
@@ -16,8 +16,7
16 require 'fileutils'
16 require 'fileutils'
17
17
18 class TestRequest < Task
18 class TestRequest < Task
19 -
19 + self.table_name = "test_requests"
20 - set_table_name "test_requests"
21
20
22 belongs_to :user
21 belongs_to :user
23 belongs_to :problem
22 belongs_to :problem
@@ -1,4 +1,4
1 class Testcase < ActiveRecord::Base
1 class Testcase < ActiveRecord::Base
2 belongs_to :problem
2 belongs_to :problem
3 - attr_accessible :group, :input, :num, :score, :sol
3 + #attr_accessible :group, :input, :num, :score, :sol
4 end
4 end
@@ -8,26 +8,24
8
8
9 has_and_belongs_to_many :roles
9 has_and_belongs_to_many :roles
10
10
11 - has_many :test_requests, :order => "submitted_at DESC"
11 + has_many :test_requests, -> {order(submitted_at: DESC)}
12
12
13 - has_many :messages,
13 + has_many :messages, -> { order(created_at: DESC) },
14 :class_name => "Message",
14 :class_name => "Message",
15 - :foreign_key => "sender_id",
15 + :foreign_key => "sender_id"
16 - :order => 'created_at DESC'
17
16
18 - has_many :replied_messages,
17 + has_many :replied_messages, -> { order(created_at: DESC) },
19 :class_name => "Message",
18 :class_name => "Message",
20 - :foreign_key => "receiver_id",
19 + :foreign_key => "receiver_id"
21 - :order => 'created_at DESC'
22
20
23 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
21 has_one :contest_stat, :class_name => "UserContestStat", :dependent => :destroy
24
22
25 belongs_to :site
23 belongs_to :site
26 belongs_to :country
24 belongs_to :country
27
25
28 - has_and_belongs_to_many :contests, :uniq => true, :order => 'name'
26 + has_and_belongs_to_many :contests, -> { order(:name); uniq}
29
27
30 - scope :activated_users, :conditions => {:activated => true}
28 + scope :activated_users, -> {where activated: true}
31
29
32 validates_presence_of :login
30 validates_presence_of :login
33 validates_uniqueness_of :login
31 validates_uniqueness_of :login
You need to be logged in to leave comments. Login now