Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'rubygems'
- require 'active_record'
- ActiveRecord::Base.logger = Logger.new("/home/nraja/Garage/FCBlog/log")
- ActiveRecord::Base.colorize_logging
- ActiveRecord::Base.establish_connection(
- :adapter => "mysql",
- :host => "127.0.0.1",
- :username => "fossconf",
- :password => "fossconf",
- :database => "fossconf"
- )
- ActiveRecord::Schema.define do
- create_table :posts do |table|
- table.column :title, :string
- table.column :content, :string
- table.column :created_at, :datetime
- table.column :user_id, :string
- table.column :category_id, :integer
- end
- create_table :comments do |table|
- table.column :post_id, :integer
- table.column :title, :string
- table.column :content, :string
- table.column :created_at, :datetime
- table.column :user_id, :integer
- end
- create_table :users do |table|
- table.column :name, :string
- table.column :email, :string
- table.column :url, :string
- end
- create_table :categories do |table|
- table.column :category, :string
- end
- end
- class Post < ActiveRecord::Base
- has_many :comments
- belongs_to_many :categories
- belongs_to :user
- end
- class Comment < ActiveRecord::Base
- belongs_to :user
- belongs_to :post
- end
- class User < ActiveRecord::Base
- has_many :comments
- has_many :posts
- end
- class Category < ActiveRecord::Base
- has_many :posts
- end
Add Comment
Please, Sign In to add comment