diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-11-03 09:06:42 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-11-03 09:06:42 +0000 |
commit | 8c512a1caffa11d1522cef5d2a35e2888c608581 (patch) | |
tree | 4fc18e0b02824638eb87d815231f470b9523231a /activerecord/test/fixtures | |
parent | f109bfb765fd54ef8bb94751c671a097089d7f53 (diff) | |
download | rails-8c512a1caffa11d1522cef5d2a35e2888c608581.tar.gz rails-8c512a1caffa11d1522cef5d2a35e2888c608581.tar.bz2 rails-8c512a1caffa11d1522cef5d2a35e2888c608581.zip |
Added extension capabilities to has_many and has_and_belongs_to_many proxies [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2861 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/fixtures')
-rw-r--r-- | activerecord/test/fixtures/developer.rb | 8 | ||||
-rw-r--r-- | activerecord/test/fixtures/post.rb | 16 |
2 files changed, 20 insertions, 4 deletions
diff --git a/activerecord/test/fixtures/developer.rb b/activerecord/test/fixtures/developer.rb index 1a4f0648bb..336b48f087 100644 --- a/activerecord/test/fixtures/developer.rb +++ b/activerecord/test/fixtures/developer.rb @@ -1,5 +1,11 @@ class Developer < ActiveRecord::Base - has_and_belongs_to_many :projects + has_and_belongs_to_many :projects, :extend => Module.new { + def find_most_recent + find(:first, :order => "id DESC") + end + } + + has_and_belongs_to_many :special_projects, :join_table => 'developers_projects', :association_foreign_key => 'project_id' validates_inclusion_of :salary, :in => 50000..200000 diff --git a/activerecord/test/fixtures/post.rb b/activerecord/test/fixtures/post.rb index f5adac41dc..6163ec90f8 100644 --- a/activerecord/test/fixtures/post.rb +++ b/activerecord/test/fixtures/post.rb @@ -1,7 +1,17 @@ class Post < ActiveRecord::Base - belongs_to :author - has_many :comments, :order => "body" - has_one :very_special_comment, :class_name => "VerySpecialComment" + belongs_to :author, :extend => Module.new { + def greeting + "hello" + end + } + + has_many :comments, :order => "body", :extend => Module.new { + def find_most_recent + find(:first, :order => "id DESC") + end + } + + has_many :special_comments, :class_name => "SpecialComment" has_and_belongs_to_many :categories has_and_belongs_to_many :special_categories, :join_table => "categories_posts" |