Class: CreateComments

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/make_commentable/templates/create_comments.rb

Class Method Summary collapse

Class Method Details

.downObject



19
20
21
# File 'lib/generators/make_commentable/templates/create_comments.rb', line 19

def self.down
  drop_table :comments
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/generators/make_commentable/templates/create_comments.rb', line 2

def self.up
  create_table :comments do |t|
    t.string :content, :null => false

    t.references :commentable, :polymorphic => true
    t.references :user

    # awesome nested set options
    t.integer :parent_id
    t.integer :lft
    t.integer :rgt
    t.integer :depth # this is optional.

    t.timestamps
  end
end