##// END OF EJS Templates
Rails3: model: replace deprecated validate method at watcher model...
Toshi MARUYAMA -
r7952:bddd19c1e662
parent child
Show More
@@ -21,6 +21,7 class Watcher < ActiveRecord::Base
21
21
22 validates_presence_of :user
22 validates_presence_of :user
23 validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
23 validates_uniqueness_of :user_id, :scope => [:watchable_type, :watchable_id]
24 validate :validate_user
24
25
25 # Unwatch things that users are no longer allowed to view
26 # Unwatch things that users are no longer allowed to view
26 def self.prune(options={})
27 def self.prune(options={})
@@ -37,7 +38,7 class Watcher < ActiveRecord::Base
37
38
38 protected
39 protected
39
40
40 def validate
41 def validate_user
41 errors.add :user_id, :invalid unless user.nil? || user.active?
42 errors.add :user_id, :invalid unless user.nil? || user.active?
42 end
43 end
43
44
General Comments 0
You need to be logged in to leave comments. Login now