Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
048_remove_count_caching.rb
Package: typo-5.4.4.zip [view]
Upload User: netsea168
Upload Date: 2022-07-22
Package Size: 4652k
Code Size: 1k
Category:
Ajax
Development Platform:
Others
- class RemoveCountCaching < ActiveRecord::Migration
- class Content < ActiveRecord::Base
- include BareMigration
- def count_children_of_type(type)
- self.class.find(:all,
- :conditions => ["article_id = ? and type = ?",
- self.id, type]).size
- end
- def correct_counts
- self.comments_count = self.count_children_of_type('Comment')
- self.trackbacks_count = self.count_children_of_type('Trackback')
- end
- end
- def self.up
- remove_column :contents, :comments_count
- remove_column :contents, :trackbacks_count
- end
- def self.down
- modify_tables_and_update(
- [:add_column, Content, :comments_count, :integer],
- [:add_column, Content, :trackbacks_count, :integer]) do |a|
- if not $schema_generator
- a.correct_counts
- end
- end
- end
- end