Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class AddCounterCacheToTags < ActiveRecord::Migration
- def self.up
- add_column :tags, :taggings_count, :integer, :default=>0
- Tag.reset_column_information
- Tag.find(:all).each do |tag|
- tag.update_attribute :taggings_count, tag.taggings.length
- end
- end
- def self.down
- remove_column :tags, :taggings_count
- end
- end
Add Comment
Please, Sign In to add comment