public
Description: El Dorado is a full-stack community web application written in Ruby/Rails.
Homepage: http://almosteffortless.com/eldorado/
Clone URL: git://github.com/trevorturk/el-dorado.git
fixing issue with named_scope and times 
[http://railscasts.com/episodes/108]
trevorturk (author)
Wed May 28 08:35:50 -0700 2008
commit  35da5a9d80722d3ac5e377f0b03da4d32218d856
tree    76f7d978dc7b1dbfcba37523ef2c26ede177e88a
parent  26566c27f93aba5a848ec598cb96908d3c9dc6bf
...
6
7
8
9
 
10
11
12
...
6
7
8
 
9
10
11
12
0
@@ -6,7 +6,7 @@ class Event < ActiveRecord::Base
0
   
0
   attr_protected :id, :created_at, :updated_at
0
   
0
- named_scope :reminders, :conditions => {:reminder => true, :date => Time.now.utc-2.hours..Time.now.utc+6.hours}, :order => 'date asc'
0
+ named_scope :reminders, lambda {|*args| {:conditions => {:reminder => true, :date => Time.now.utc-2.hours..Time.now.utc+6.hours}, :order => 'date asc'}}
0
   
0
   def to_s
0
     title
...
23
24
25
26
27
28
29
30
 
31
32
33
...
42
43
44
 
 
 
 
45
46
47
...
23
24
25
 
 
 
 
 
26
27
28
29
...
38
39
40
41
42
43
44
45
46
47
0
@@ -23,11 +23,7 @@ class Topic < ActiveRecord::Base
0
   def hit!
0
     self.class.increment_counter(:views, id)
0
   end
0
-
0
- def updated_at
0
- last_post_at
0
- end
0
-
0
+
0
   def replies
0
     self.posts_count - 1
0
   end
0
@@ -42,6 +38,10 @@ class Topic < ActiveRecord::Base
0
     self.class.update_all(['last_post_id = ?, last_post_at = ?, last_post_by = ?', post.id, post.created_at, post.user_id], ['id = ?', self.id])
0
   end
0
   
0
+ def updated_at
0
+ last_post_at
0
+ end
0
+
0
   def to_s
0
     title
0
   end
...
25
26
27
28
29
30
31
32
33
34
35
36
 
 
 
37
38
39
...
51
52
53
 
 
 
 
 
 
54
55
56
...
25
26
27
 
 
 
 
 
 
 
 
 
28
29
30
31
32
33
...
45
46
47
48
49
50
51
52
53
54
55
56
0
@@ -25,15 +25,9 @@ class User < ActiveRecord::Base
0
   
0
   attr_protected :id, :created_at, :admin, :posts_count
0
   
0
- named_scope :chatting, :conditions => ['chatting_at > ?', Time.now.utc-30.seconds], :order => 'login asc'
0
- named_scope :online, :conditions => ['logged_out = ? and (online_at > ? or chatting_at > ?)', false, Time.now.utc-5.minutes, Time.now.utc-30.seconds], :order => 'login asc'
0
-
0
- def password=(value)
0
- return if value.blank?
0
- write_attribute :password_hash, User.encrypt(value)
0
- @password = value
0
- end
0
-
0
+ named_scope :chatting, lambda {|*args| {:conditions => ['chatting_at > ?', Time.now.utc-30.seconds], :order => 'login asc'}}
0
+ named_scope :online, lambda {|*args| {:conditions => ['logged_out = ? and (online_at > ? or chatting_at > ?)', false, Time.now.utc-5.minutes, Time.now.utc-30.seconds], :order => 'login asc'}}
0
+
0
   def updated_at
0
     profile_updated_at
0
   end
0
@@ -51,6 +45,12 @@ class User < ActiveRecord::Base
0
     self.save
0
   end
0
   
0
+ def password=(value)
0
+ return if value.blank?
0
+ write_attribute :password_hash, User.encrypt(value)
0
+ @password = value
0
+ end
0
+
0
   def self.authenticate(login, password)
0
     find_by_login_and_password_hash(login, encrypt(password))
0
   end

Comments

    No one has commented yet.