Permalink
Browse files

Add Comment Model

  • Loading branch information...
1 parent 5ea7da1 commit 574655f749d06bb2a41157a4ea18b86bf58155e3 @yannr77 committed Jan 27, 2012
Showing with 44 additions and 2 deletions.
  1. +3 −0 app/models/comment.rb
  2. +0 −1 blog
  3. +12 −0 db/migrate/20120127092949_create_comments.rb
  4. +11 −1 db/schema.rb
  5. +11 −0 test/fixtures/comments.yml
  6. +7 −0 test/unit/comment_test.rb
View
@@ -0,0 +1,3 @@
+class Comment < ActiveRecord::Base
+ belongs_to :post
+end
View
1 blog
@@ -0,0 +1,12 @@
+class CreateComments < ActiveRecord::Migration
+ def change
+ create_table :comments do |t|
+ t.string :commenter
+ t.text :body
+ t.references :post
+
+ t.timestamps
+ end
+ add_index :comments, :post_id
+ end
+end
View
@@ -11,7 +11,17 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120126170944) do
+ActiveRecord::Schema.define(:version => 20120127092949) do
+
+ create_table "comments", :force => true do |t|
+ t.string "commenter"
+ t.text "body"
+ t.integer "post_id"
+ t.datetime "created_at"
+ t.datetime "updated_at"
+ end
+
+ add_index "comments", ["post_id"], :name => "index_comments_on_post_id"
create_table "posts", :force => true do |t|
t.string "name"
View
@@ -0,0 +1,11 @@
+# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
+
+one:
+ commenter: MyString
+ body: MyText
+ post:
+
+two:
+ commenter: MyString
+ body: MyText
+ post:
@@ -0,0 +1,7 @@
+require 'test_helper'
+
+class CommentTest < ActiveSupport::TestCase
+ # test "the truth" do
+ # assert true
+ # end
+end

0 comments on commit 574655f

Please sign in to comment.