diff options
author | Arun Agrawal <arun@fromjaipur.com> | 2011-06-03 08:28:00 +0530 |
---|---|---|
committer | Arun Agrawal <arun@fromjaipur.com> | 2011-06-03 08:28:00 +0530 |
commit | 0695eb6dac751e0e46bb9fd0ac5d70c0a94a86b1 (patch) | |
tree | a54761f38e34a631424fa36b0d84614da40a2907 /activerecord/test/models | |
parent | f064664de72a34d24568eadf7340f41876df4b20 (diff) | |
download | rails-0695eb6dac751e0e46bb9fd0ac5d70c0a94a86b1.tar.gz rails-0695eb6dac751e0e46bb9fd0ac5d70c0a94a86b1.tar.bz2 rails-0695eb6dac751e0e46bb9fd0ac5d70c0a94a86b1.zip |
Test added for namedscope target.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/comment.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index 2a4c37089a..43650c0427 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -6,7 +6,8 @@ class Comment < ActiveRecord::Base scope :for_first_author, :joins => :post, :conditions => { "posts.author_id" => 1 } - + scope :created + belongs_to :post, :counter_cache => true has_many :ratings diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index f2ab7b053e..affa37b02d 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -36,6 +36,10 @@ class Post < ActiveRecord::Base def find_most_recent find(:first, :order => "id DESC") end + + def newest + created.last + end end has_many :author_favorites, :through => :author |