[英]acts_As_taggabe_on changing case of tags - possibly caching issue but not sure
我正在使用actastaggableon寶石。 由於某些原因,系統會將標簽“ Python”保存為“ python(小寫)”。 由於我正在驗證用戶只能輸入某些標簽,因此將標簽另存為“ python”的系統會引起一些問題。 以下是我的服務器日志。 第一行是所有驗證運行(通過)之后的tag_list的puts語句。 然后,服務器執行一些奇怪的操作,並將“ Python”轉換為“ python”。 這可能與緩存有關,因為我以前有一個名為“ python”的標簽,但我不再這樣做。 如何在不認真更改緩存設置的情況下解決此問題?
["IOS | IPhone | IPad", "App and Web development", "PHP", "Rails", "Python"]
ActsAsTaggableOn::Tag Load (0.8ms) SELECT "tags".* FROM "tags" WHERE (lower(name) = 'ios | iphone | ipad' OR lower(name) = 'app and web development' OR lower(name) = 'php' OR lower(name) = 'rails' OR lower(name) = 'python')
ActsAsTaggableOn::Tag Load (0.8ms) SELECT "tags".* FROM "tags" WHERE (lower(name) = 'ios | iphone | ipad' OR lower(name) = 'app and web development' OR lower(name) = 'php' OR lower(name) = 'rails' OR lower(name) = 'python')
CACHE (0.0ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL) [["taggable_id", 16], ["taggable_type", "Profile"]]
CACHE (0.0ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."taggable_id" = $1 AND "taggings"."taggable_type" = $2 AND (taggings.context = 'tags' AND taggings.tagger_id IS NULL) [["taggable_id", 16], ["taggable_type", "Profile"]]
ActsAsTaggableOn::Tagging Exists (0.6ms) SELECT 1 AS one FROM "taggings" WHERE ("taggings"."tag_id" = 1 AND "taggings"."taggable_type" = 'Profile' AND "taggings"."taggable_id" = 16 AND "taggings"."context" = 'tags' AND "taggings"."tagger_id" IS NULL AND "taggings"."tagger_type" IS NULL) LIMIT 1
ActsAsTaggableOn::Tagging Exists (0.6ms) SELECT 1 AS one FROM "taggings" WHERE ("taggings"."tag_id" = 1 AND "taggings"."taggable_type" = 'Profile' AND "taggings"."taggable_id" = 16 AND "taggings"."context" = 'tags' AND "taggings"."tagger_id" IS NULL AND "taggings"."tagger_type" IS NULL) LIMIT 1
SQL (3.8ms) INSERT INTO "taggings" ("context", "created_at", "tag_id", "taggable_id", "taggable_type") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["context", "tags"], ["created_at", Tue, 25 Mar 2014 16:05:41 EDT -04:00], ["tag_id", 1], ["taggable_id", 16], ["taggable_type", "Profile"]]
SQL (3.8ms) INSERT INTO "taggings" ("context", "created_at", "tag_id", "taggable_id", "taggable_type") VALUES ($1, $2, $3, $4, $5) RETURNING "id" [["context", "tags"], ["created_at", Tue, 25 Mar 2014 16:05:41 EDT -04:00], ["tag_id", 1], ["taggable_id", 16], ["taggable_type", "Profile"]]
您是否在某處設置了此設置:
ActsAsTaggableOn.force_lowercase = true
如果是這樣,則強制小寫
如果沒有該設置,則另一個可能的問題是,如果您正在使用mysql作為數據庫,可以在以下位置找到: https : //github.com/mbleigh/acts-as-taggable-on/issues/259
class EditTagTableToBeCaseSensitive < ActiveRecord::Migration
def up
@sql = "ALTER TABLE `tags` CHANGE `name` `name` VARCHAR(255) BINARY DEFAULT NULL;"
execute @sql
end
def down
@sql = "ALTER TABLE `tags` CHANGE `name` `name` VARCHAR(255) DEFAULT NULL;"
execute @sql
end
end
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.