require 'rubygems' require_gem 'activerecord' ActiveRecord::Base.pluralize_table_names = false ActiveRecord::Base.primary_key_prefix_type = :table_name_with_underscore ActiveRecord::Base.table_name_prefix = 'mt_' module MT class Author < ActiveRecord::Base has_many :categories, :foreign_key => 'category_author_id' has_many :entries, :foreign_key => 'entry_author_id' has_many :permissions, :foreign_key => 'permission_author_id' has_and_belongs_to_many :blogs, :join_table => 'mt_permission', :foreign_key => 'permission_author_id', :association_foreign_key => 'permission_blog_id' end class Blog < ActiveRecord::Base has_many :categories, :foreign_key => 'category_blog_id' has_many :comments, :foreign_key => 'comment_blog_id' has_many :entries, :foreign_key => 'entry_blog_id' has_many :fileinfos, :foreign_key => 'fileinfo_blog_id' has_many :ipbanlists, :foreign_key => 'ipbanlist_blog_id' has_many :notifications, :foreign_key => 'notification_blog_id' has_many :placements, :foreign_key => 'placement_blog_id' has_many :tbpings, :foreign_key => 'tbping_blog_id' has_many :templates, :foreign_key => 'template_blog_id' has_many :templatemaps, :foreign_key => 'templatemap_blog_id' has_many :trackbacks, :foreign_key => 'trackback_blog_id' has_and_belongs_to_many :authors, :join_table => 'mt_permission', :foreign_key => 'permission_blog_id', :association_foreign_key => 'permission_author_id' end class Category < ActiveRecord::Base belongs_to :blog, :foreign_key => 'category_blog_id' belongs_to :author, :foreign_key => 'category_author_id' has_many :placements, :foreign_key => 'placement_category_id' has_and_belongs_to_many :entries, :join_table => 'mt_placement', :foreign_key => 'placement_category_id', :association_foreign_key => 'placement_entry_id' end class Comment < ActiveRecord::Base belongs_to :blog, :foreign_key => 'comment_blog_id' belongs_to :entry, :foreign_key => 'comment_entry_id' belongs_to :commenter, :class_name => 'Author', :foreign_key => 'comment_commenter_id' end class Entry < ActiveRecord::Base belongs_to :blog, :foreign_key => 'entry_blog_id' belongs_to :author, :foreign_key => 'entry_author_id' has_one :trackback, :foreign_key => 'trackback_entry_id' has_many :comments, :foreign_key => 'comment_entry_id' has_many :fileinfos, :foreign_key => 'fileinfo_entry_id' has_many :placements, :foreign_key => 'placement_entry_id' has_and_belongs_to_many :categories, :join_table => 'mt_placement', :foreign_key => 'placement_entry_id', :association_foreign_key => 'placement_category_id' has_and_belongs_to_many :tbpings, :finder_sql => 'SELECT t.* FROM mt_trackback j, mt_tbping t WHERE t.tbping_tb_id = j.trackback_id AND j.trackback_entry_id= #{entry_id} ORDER BY t.tbping_id' end class Fileinfo < ActiveRecord::Base belongs_to :blog, :foreign_key => 'fileinfo_blog_id' belongs_to :entry, :foreign_key => 'fileinfo_entry_id' belongs_to :template, :foreign_key => 'fileinfo_template_id' belongs_to :templatemap, :foreign_key => 'fileinfo_templatemap_id' belongs_to :category, :foreign_key => 'fileinfo_category_id' end class Ipbanlist < ActiveRecord::Base belongs_to :blog, :foreign_key => 'ipbanlist_blog_id' end class Log < ActiveRecord::Base end class Notification < ActiveRecord::Base belongs_to :blog, :foreign_key => 'notification_blog_id' end class Permission < ActiveRecord::Base belongs_to :author, :foreign_key => 'permission_author_id' belongs_to :blog, :foreign_key => 'permission_blog_id' end class Placement < ActiveRecord::Base belongs_to :entry, :foreign_key => 'placement_entry_id' belongs_to :blog, :foreign_key => 'placement_blog_id' belongs_to :category, :foreign_key => 'placement_category_id' end class Plugindata < ActiveRecord::Base end class Session < ActiveRecord::Base end class Tbping < ActiveRecord::Base belongs_to :blog, :foreign_key => 'tbping_blog_id' belongs_to :trackback, :foreign_key => 'tbping_tb_id' end class Template < ActiveRecord::Base belongs_to :blog, :foreign_key => 'template_blog_id' end class Templatemap < ActiveRecord::Base belongs_to :blog, :foreign_key => 'templatemap_blog_id' belongs_to :template, :foreign_key => 'templatemap_template_id' end class Trackback < ActiveRecord::Base belongs_to :blog, :foreign_key => 'trackback_blog_id' belongs_to :entry, :foreign_key => 'trackback_entry_id' belongs_to :category, :foreign_key => 'trackback_category_id' has_many :tbpings, :foreign_key => 'tbping_tb_id' end end