diff options
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/author.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/comment.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 2 | ||||
-rwxr-xr-x | activerecord/test/models/topic.rb | 28 |
4 files changed, 34 insertions, 0 deletions
diff --git a/activerecord/test/models/author.rb b/activerecord/test/models/author.rb index 523d794fb3..79a121b4a4 100644 --- a/activerecord/test/models/author.rb +++ b/activerecord/test/models/author.rb @@ -3,6 +3,7 @@ class Author < ActiveRecord::Base has_many :posts_with_comments, :include => :comments, :class_name => "Post" has_many :posts_with_categories, :include => :categories, :class_name => "Post" has_many :posts_with_comments_and_categories, :include => [ :comments, :categories ], :order => "posts.id", :class_name => "Post" + has_many :posts_containing_the_letter_a, :class_name => "Post" has_many :posts_with_extension, :class_name => "Post" do #, :extend => ProxyTestExtension def testing_proxy_owner proxy_owner @@ -15,6 +16,7 @@ class Author < ActiveRecord::Base end end has_many :comments, :through => :posts + has_many :comments_containing_the_letter_e, :through => :posts, :source => :comments has_many :comments_desc, :through => :posts, :source => :comments, :order => 'comments.id DESC' has_many :limited_comments, :through => :posts, :source => :comments, :limit => 1 has_many :funky_comments, :through => :posts, :source => :comments diff --git a/activerecord/test/models/comment.rb b/activerecord/test/models/comment.rb index 73ebdadf73..f7f07c103f 100644 --- a/activerecord/test/models/comment.rb +++ b/activerecord/test/models/comment.rb @@ -1,4 +1,6 @@ class Comment < ActiveRecord::Base + named_scope :containing_the_letter_e, :conditions => "comments.body LIKE '%e%'" + belongs_to :post, :counter_cache => true def self.what_are_you diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 7f9d53b34b..fcfe260d4a 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -1,4 +1,6 @@ class Post < ActiveRecord::Base + named_scope :containing_the_letter_a, :conditions => "body LIKE '%a%'" + belongs_to :author do def greeting "hello" diff --git a/activerecord/test/models/topic.rb b/activerecord/test/models/topic.rb index 17e91e4b13..0ef7be97d3 100755 --- a/activerecord/test/models/topic.rb +++ b/activerecord/test/models/topic.rb @@ -1,4 +1,32 @@ class Topic < ActiveRecord::Base + named_scope :written_before, lambda { |time| + { :conditions => ['written_on < ?', time] } + } + named_scope :approved, :conditions => {:approved => true} + named_scope :replied, :conditions => ['replies_count > 0'] + named_scope :anonymous_extension do + def one + 1 + end + end + module NamedExtension + def two + 2 + end + end + module MultipleExtensionOne + def extension_one + 1 + end + end + module MultipleExtensionTwo + def extension_two + 2 + end + end + named_scope :named_extension, :extend => NamedExtension + named_scope :multiple_extensions, :extend => [MultipleExtensionTwo, MultipleExtensionOne] + has_many :replies, :dependent => :destroy, :foreign_key => "parent_id" serialize :content |