Sha256: 1d6d3e1a06f360eaedb948030fbc29c1dc3c6a1988df05dfc77ab5790000aa04

Contents?: true

Size: 875 Bytes

Versions: 22

Compression:

Stored size: 875 Bytes

Contents

class ActsAsTaggableOnMigration < ActiveRecord::Migration
  def self.up
    
    rename_column :contents, :tags, :old_tags
    
    create_table :tags do |t|
      t.string :name
    end

    create_table :taggings do |t|
      t.references :tag

      # You should make sure that the column created is
      # long enough to store the required class names.
      t.references :taggable, :polymorphic => true
      t.references :tagger, :polymorphic => true

      t.string :context

      t.datetime :created_at
    end

    add_index :taggings, :tag_id
    add_index :taggings, [:taggable_id, :taggable_type, :context]
    
    Kuhsaft::PagePart::Content.all.each do |c|
      c.tag_list = c.old_tags.gsub(' ', ', ') unless c.old_tags.blank?
    end
    
    remove_column(:contents, :old_tags)
  end

  def self.down
    drop_table :taggings
    drop_table :tags
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
kuhsaft-0.2.legacy4 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4.legacy3 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.legacy3 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.legacy2 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.legacy lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4.legacy2 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4.legacy lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.6 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.5 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4.rc2 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.4.rc1 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.3 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.2 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.5 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.4 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.3 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.1 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.3.0 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb
kuhsaft-0.2.2 lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb