views:

58

answers:

1

To truncate an ActiveRecord table, I can do

Category.destroy_all

or

Post.destroy_all

How does one go about truncating a categories_post table?

A: 

I guess your join table is called categories_posts. CategoryPost.destroy_all should work, if not, maybe you need to specify the table name in the model (CategoryPost)

set_table_name "categories_posts"

Update, there isn't a CategoryPost model, so it should be created:

class CategoryPost < ActiveRecord::Base
  set_table_name "categories_posts"
end 
jordinl
@jordinl, join tables don't have an associated model. e.g., `CategoryPost`
macek
you can create it
jordinl