Skip to content

anonymous /comment.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Basic ruby blog model set up
class Comment < ActiveRecord::Base
attr_accessible :content, :score
has_one :user
belongs_to :post
end
class CreateComments < ActiveRecord::Migration
def change
create_table :comments do |t|
t.text :content
t.integer :score
t.timestamps
end
end
end
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :content
t.integer :score
t.timestamps
end
end
end
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :password
t.integer :score
t.timestamps
end
end
end
class Post < ActiveRecord::Base
attr_accessible :title, :content, :score
has_one :user
has_many :comments
end
ActiveRecord::Schema.define(:version => 20120821235424) do
create_table "comments", :force => true do |t|
t.text "content"
t.integer "score"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "posts", :force => true do |t|
t.string "title"
t.text "content"
t.integer "score"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
create_table "users", :force => true do |t|
t.string "name"
t.string "email"
t.string "password"
t.integer "score"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
end
class User < ActiveRecord::Base
attr_accessible :name, :email :password, :score
has_many :posts
has_many :comments
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.