Class: CreateComments
- Inherits:
-
Object
- Object
- CreateComments
- Defined in:
- lib/generators/comment/templates/create_comments.rb
Class Method Summary collapse
Class Method Details
.down ⇒ Object
17 18 19 |
# File 'lib/generators/comment/templates/create_comments.rb', line 17 def self.down drop_table :comments end |
.up ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/generators/comment/templates/create_comments.rb', line 2 def self.up create_table :comments do |t| t.string :title, limit: 50, default: '' t.text :comment t.references :commentable, polymorphic: true t.references :user t.string :role, default: 'comments' t. end add_index :comments, :commentable_type add_index :comments, :commentable_id add_index :comments, :user_id unless index_exists?(:comments, :user_id) end |