configures act_as_taggable [#8]
This commit is contained in:
2
Gemfile
2
Gemfile
@@ -31,7 +31,7 @@ gem 'devise'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
gem 'acts-as-taggable-on'
|
||||
gem "responders"
|
||||
gem 'foundation-rails'
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ GEM
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
acts-as-taggable-on (3.5.0)
|
||||
activerecord (>= 3.2, < 5)
|
||||
arel (6.0.2)
|
||||
bcrypt (3.1.10)
|
||||
binding_of_caller (0.7.2)
|
||||
@@ -188,6 +190,7 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts-as-taggable-on
|
||||
byebug
|
||||
capybara
|
||||
coffee-rails (~> 4.1.0)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
class Debate < ActiveRecord::Base
|
||||
acts_as_taggable
|
||||
belongs_to :author, class_name: 'User', foreign_key: 'author_id'
|
||||
|
||||
validates :title, presence: true
|
||||
|
||||
1
config/initializers/acts_as_taggable_on.rb
Normal file
1
config/initializers/acts_as_taggable_on.rb
Normal file
@@ -0,0 +1 @@
|
||||
ActsAsTaggableOn.delimiter = ','
|
||||
@@ -0,0 +1,25 @@
|
||||
# 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
|
||||
t.references :taggable, polymorphic: true
|
||||
t.references :tagger, polymorphic: true
|
||||
t.string :context, limit: 128
|
||||
t.datetime :created_at
|
||||
end
|
||||
|
||||
add_index :tags, :name, unique: true
|
||||
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
|
||||
@@ -0,0 +1,10 @@
|
||||
# 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
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :tags, :taggings_count
|
||||
end
|
||||
end
|
||||
22
db/schema.rb
22
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20150717164054) do
|
||||
ActiveRecord::Schema.define(version: 20150718075337) do
|
||||
|
||||
create_table "debates", force: :cascade do |t|
|
||||
t.string "title"
|
||||
@@ -21,6 +21,26 @@ ActiveRecord::Schema.define(version: 20150717164054) do
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "taggings", force: :cascade do |t|
|
||||
t.integer "tag_id"
|
||||
t.integer "taggable_id"
|
||||
t.string "taggable_type"
|
||||
t.integer "tagger_id"
|
||||
t.string "tagger_type"
|
||||
t.string "context", limit: 128
|
||||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id"
|
||||
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
||||
|
||||
create_table "tags", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.integer "taggings_count", default: 0
|
||||
end
|
||||
|
||||
add_index "tags", ["name"], name: "index_tags_on_name", unique: true
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "email", default: "", null: false
|
||||
t.string "encrypted_password", default: "", null: false
|
||||
|
||||
Reference in New Issue
Block a user