aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-08-29 11:49:23 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-08-29 11:49:23 -0700
commit44046d0782be0737ec68964695a63a56727d17e1 (patch)
treea0aa3fc50d493efbd2f0bc775514425d0137a5b2 /activerecord/test/models
parent0b3a078a24819fae8b9df0b0f63a264cece70a7c (diff)
downloadrails-44046d0782be0737ec68964695a63a56727d17e1.tar.gz
rails-44046d0782be0737ec68964695a63a56727d17e1.tar.bz2
rails-44046d0782be0737ec68964695a63a56727d17e1.zip
pk should not be required for hm:t associations
Diffstat (limited to 'activerecord/test/models')
-rw-r--r--activerecord/test/models/post.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 93a7a2073c..25fb2cffe2 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -1,4 +1,10 @@
class Post < ActiveRecord::Base
+ class CategoryPost < ActiveRecord::Base
+ self.table_name = "categories_posts"
+ belongs_to :category
+ belongs_to :post
+ end
+
module NamedExtension
def author
'lifo'
@@ -72,6 +78,8 @@ class Post < ActiveRecord::Base
has_many :special_comments_ratings, :through => :special_comments, :source => :ratings
has_many :special_comments_ratings_taggings, :through => :special_comments_ratings, :source => :taggings
+ has_many :category_posts, :class_name => 'CategoryPost'
+ has_many :scategories, through: :category_posts, source: :category
has_and_belongs_to_many :categories
has_and_belongs_to_many :special_categories, :join_table => "categories_posts", :association_foreign_key => 'category_id'