categorization has_many :through should have an ID, and the relationship should be destroyed if the blog post or category is

This commit is contained in:
Joe Sak 2011-07-18 14:56:46 -05:00
parent 98b6052f1f
commit b78486ce1e
3 changed files with 3 additions and 3 deletions

View file

@ -1,6 +1,6 @@
class BlogCategory < ActiveRecord::Base
has_many :categorizations
has_many :categorizations, :dependent => :destroy
has_many :posts, :through => :categorizations, :source => :blog_post
acts_as_indexed :fields => [:title]

View file

@ -13,7 +13,7 @@ class BlogPost < ActiveRecord::Base
has_many :comments, :class_name => 'BlogComment', :dependent => :destroy
acts_as_taggable
has_many :categorizations
has_many :categorizations, :dependent => :destroy
has_many :categories, :through => :categorizations, :source => :blog_category
acts_as_indexed :fields => [:title, :body]

View file

@ -30,7 +30,7 @@ class CreateBlogStructure < ActiveRecord::Migration
add_index :blog_categories, :id
create_table :blog_categories_blog_posts, :id => false do |t|
create_table :blog_categories_blog_posts, :id => true do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end