-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from divyanshumehta/exp2
Added Tagging system with autocomplete feature
- Loading branch information
Showing
17 changed files
with
183 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
db/migrate/20170127162437_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 1) | ||
class ActsAsTaggableOnMigration < ActiveRecord::Migration | ||
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 | ||
|
||
def self.down | ||
drop_table :taggings | ||
drop_table :tags | ||
end | ||
end |
21 changes: 21 additions & 0 deletions
21
db/migrate/20170127162438_add_missing_unique_indices.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 2) | ||
class AddMissingUniqueIndices < ActiveRecord::Migration | ||
def self.up | ||
add_index :tags, :name, unique: true | ||
|
||
remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id) | ||
remove_index :taggings, [:taggable_id, :taggable_type, :context] | ||
add_index :taggings, | ||
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, | ||
:tagger_type], unique: true, name: 'taggings_idx' | ||
end | ||
|
||
def self.down | ||
remove_index :tags, :name | ||
|
||
remove_index :taggings, name: 'taggings_idx' | ||
|
||
add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id) | ||
add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
end | ||
end |
15 changes: 15 additions & 0 deletions
15
db/migrate/20170127162439_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 3) | ||
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration | ||
def self.up | ||
add_column :tags, :taggings_count, :integer, default: 0 | ||
|
||
ActsAsTaggableOn::Tag.reset_column_information | ||
ActsAsTaggableOn::Tag.find_each do |tag| | ||
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings) | ||
end | ||
end | ||
|
||
def self.down | ||
remove_column :tags, :taggings_count | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
db/migrate/20170127162440_add_missing_taggable_index.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 4) | ||
class AddMissingTaggableIndex < ActiveRecord::Migration | ||
def self.up | ||
add_index :taggings, [:taggable_id, :taggable_type, :context] | ||
end | ||
|
||
def self.down | ||
remove_index :taggings, [:taggable_id, :taggable_type, :context] | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
db/migrate/20170127162441_change_collation_for_tag_names.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 5) | ||
# This migration is added to circumvent issue #623 and have special characters | ||
# work properly | ||
class ChangeCollationForTagNames < ActiveRecord::Migration | ||
def up | ||
if ActsAsTaggableOn::Utils.using_mysql? | ||
execute('ALTER TABLE tags MODIFY name varchar(255) CHARACTER | ||
SET utf8 COLLATE utf8_bin;') | ||
end | ||
end | ||
end |
14 changes: 14 additions & 0 deletions
14
db/migrate/20170127162442_add_missing_indexes.acts_as_taggable_on_engine.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This migration comes from acts_as_taggable_on_engine (originally 6) | ||
class AddMissingIndexes < ActiveRecord::Migration | ||
def change | ||
add_index :taggings, :tag_id | ||
add_index :taggings, :taggable_id | ||
add_index :taggings, :taggable_type | ||
add_index :taggings, :tagger_id | ||
add_index :taggings, :context | ||
|
||
add_index :taggings, [:tagger_id, :tagger_type] | ||
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, | ||
:context], name: 'taggings_idy' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters