Skip to content
Browse files

Generate Comment model

  • Loading branch information...
1 parent 7121d4c commit 144493f571aa346b1ad1d70ccba800c5d48e507a @prathe committed
Showing with 30 additions and 0 deletions.
  1. +3 −0 app/models/comment.rb
  2. +11 −0 db/migrate/20120217033312_create_comments.rb
  3. +9 −0 test/fixtures/comments.yml
  4. +7 −0 test/unit/comment_test.rb
View
3 app/models/comment.rb
@@ -0,0 +1,3 @@
+class Comment < ActiveRecord::Base
+ belongs_to :post
+end
View
11 db/migrate/20120217033312_create_comments.rb
@@ -0,0 +1,11 @@
+class CreateComments < ActiveRecord::Migration
+ def change
+ create_table :comments do |t|
+ t.text :content
+ t.references :post
+
+ t.timestamps
+ end
+ add_index :comments, :post_id
+ end
+end
View
9 test/fixtures/comments.yml
@@ -0,0 +1,9 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ content: MyText
+ post:
+
+two:
+ content: MyText
+ post:
View
7 test/unit/comment_test.rb
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end

0 comments on commit 144493f

Please sign in to comment.
Something went wrong with that request. Please try again.