Created
August 22, 2012 00:10
-
-
Save anonymous/3420711 to your computer and use it in GitHub Desktop.
Basic ruby blog model set up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment < ActiveRecord::Base | |
attr_accessible :content, :score | |
has_one :user | |
belongs_to :post | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateComments < ActiveRecord::Migration | |
def change | |
create_table :comments do |t| | |
t.text :content | |
t.integer :score | |
t.timestamps | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Post < ActiveRecord::Base | |
attr_accessible :title, :content, :score | |
has_one :user | |
has_many :comments | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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