class Object

Constants

APP_PATH
APP_ROOT

path to your application root.

VENDOR_PATH

Public Class Methods

down() click to toggle source
# File db/migrate/20171111223936_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb, line 32
def self.down
  drop_table :taggings
  drop_table :tags
end
up() click to toggle source
# File db/migrate/20171111223936_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb, line 8
def self.up
  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

    # Limit is created to prevent MySQL error on index
    # length for MyISAM table type: http://bit.ly/vgW2Ql
    t.string :context, limit: 128

    t.datetime :created_at
  end

  add_index :taggings, :tag_id
  add_index :taggings, [:taggable_id, :taggable_type, :context]
end

Public Instance Methods

change() click to toggle source
# File db/migrate/20171111223941_add_missing_indexes_on_taggings.acts_as_taggable_on_engine.rb, line 8
def change
  add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
  add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
  add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
  add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
  add_index :taggings, :context unless index_exists? :taggings, :context

  unless index_exists? :taggings, [:tagger_id, :tagger_type]
    add_index :taggings, [:tagger_id, :tagger_type]
  end

  unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
    add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
  end
end
system!(*args) click to toggle source
# File bin/setup, line 9
def system!(*args)
  system(*args) || abort("\n== Command #{args} failed ==")
end
up() click to toggle source
# File db/migrate/20171111223940_change_collation_for_tag_names.acts_as_taggable_on_engine.rb, line 10
def up
  if ActsAsTaggableOn::Utils.using_mysql?
    execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
  end
end