Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug: user_id= method overshadowed real user_id method, causing …

…activerecord objects

not to retain the assigned user id. Also removed the User lookup as it was unnecessary
overhead. ActiveRecord already throws an exception if you try to save the object.
  • Loading branch information...
commit 941a8695eb7a7ae923904347434842f739b8d029 1 parent f575541
@skwp skwp authored
Showing with 108 additions and 10 deletions.
  1. +2 −9 README
  2. +2 −1  lib/acts_as_taggable.rb
  3. +104 −0 test/debug.log
View
11 README
@@ -131,14 +131,7 @@ Tag clouds are created by a helper function, and depend on the counter cache to
<%= tag_cloud %>
-
-Running tests
-=============
-
-The simplest way is to create a blank Rails project with this plugin, and run tests using the in-memory sqlite database:
-
- rake DB=sqlite3
-
+
Contributing
============
@@ -147,4 +140,4 @@ Welcoming all pull requests on github.com at http://github.com/monki/acts_as_tag
-Copyright (c) 2008 monki(Wesley Beary), released under the MIT license
+Copyright (c) 2008 monki(Wesley Beary), released under the MIT license
View
3  lib/acts_as_taggable.rb
@@ -67,7 +67,8 @@ def tag_list=(new_tag_list)
end
def user_id=(new_user_id)
- @new_user_id = User.find(new_user_id).id
+ @new_user_id = new_user_id
+ super(new_user_id)
end
def tag_list(user = nil)
View
104 test/debug.log
@@ -0,0 +1,104 @@
+# Logfile created on Thu May 15 14:17:58 -0500 2008 by logger.rb/1.5.2.9
+ SQL (0.000346) select sqlite_version(*)
+ SQL (0.000000) SQLite3::SQLException: no such table: tags: DROP TABLE tags
+ SQL (0.000336) CREATE TABLE tags ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT NULL, "taggings_count" integer DEFAULT 0 NOT NULL) 
+ SQL (0.000171) CREATE INDEX "index_tags_on_name" ON tags ("name")
+ SQL (0.000153) CREATE INDEX "index_tags_on_taggings_count" ON tags ("taggings_count")
+ SQL (0.000000) SQLite3::SQLException: no such table: taggings: DROP TABLE taggings
+ SQL (0.000188) CREATE TABLE taggings ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "tag_id" integer DEFAULT NULL, "taggable_id" integer DEFAULT NULL, "taggable_type" varchar(255) DEFAULT NULL, "user_id" integer DEFAULT NULL) 
+ SQL (0.000153) CREATE INDEX "index_taggings_on_tag_id_and_taggable_type" ON taggings ("tag_id", "taggable_type")
+ SQL (0.000166) CREATE INDEX "index_taggings_on_user_id_and_tag_id_and_taggable_type" ON taggings ("user_id", "tag_id", "taggable_type")
+ SQL (0.000156) CREATE INDEX "index_taggings_on_taggable_id_and_taggable_type" ON taggings ("taggable_id", "taggable_type")
+ SQL (0.000161) CREATE INDEX "index_taggings_on_user_id_and_taggable_id_and_taggable_type" ON taggings ("user_id", "taggable_id", "taggable_type")
+ SQL (0.000000) SQLite3::SQLException: no such table: things: DROP TABLE things
+ SQL (0.000176) CREATE TABLE things ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar(255) DEFAULT NULL) 
+ SQL (0.000000) SQLite3::SQLException: no such table: users: DROP TABLE users
+ SQL (0.000177) CREATE TABLE users ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(255) DEFAULT NULL) 
+ SQL (0.000184) CREATE TABLE schema_info (version integer)
+ SQL (0.000069) INSERT INTO schema_info (version) VALUES(0)
+ SQL (0.000082) UPDATE schema_info SET version = 0
+ Thing Load (0.000163) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000162) SELECT * FROM things WHERE (things."id" = 2) 
+ Thing Load (0.001725) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 1
+ Thing Load (0.001072) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 2
+ Thing Load (0.000946) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 1
+ Thing Load (0.000893) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','plant')) GROUP BY things_taggings.taggable_id HAVING COUNT(things_taggings.taggable_id) = 2
+ Thing Load (0.000182) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000160) SELECT * FROM things WHERE (things."id" = 2) 
+ Thing Load (0.000919) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) 
+ Thing Load (0.000181) SELECT * FROM things WHERE (things."id" = 3) 
+ Thing Load (0.000909) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) 
+ Thing Load (0.001076) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) 
+ Thing Load (0.000792) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal')) 
+ Thing Load (0.000842) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('animal','green')) 
+ Thing Load (0.000694) SELECT DISTINCT things.* FROM things LEFT OUTER JOIN taggings things_taggings ON things_taggings.taggable_id = things.id AND things_taggings.taggable_type = 'Thing' LEFT OUTER JOIN tags things_tags ON things_tags.id = things_taggings.tag_id WHERE (things_tags.name IN ('fake')) 
+ Thing Load (0.000173) SELECT * FROM things WHERE (things."id" = 1) 
+ Tag Load (0.010343) SELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc
+ Thing Load (0.000226) SELECT * FROM things WHERE (things."id" = 2) 
+ Tag Load (0.000703) SELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 2)) ORDER BY name asc
+ Thing Load (0.000232) SELECT * FROM things WHERE (things."id" = 1) 
+ Tag Load (0.000751) SELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc
+ Tagging Load Including Associations (0.000550) SELECT taggings."id" AS t0_r0, taggings."tag_id" AS t0_r1, taggings."taggable_id" AS t0_r2, taggings."taggable_type" AS t0_r3, taggings."user_id" AS t0_r4, tags."id" AS t1_r0, tags."name" AS t1_r1, tags."taggings_count" AS t1_r2 FROM taggings LEFT OUTER JOIN tags ON tags.id = taggings.tag_id WHERE (taggings.taggable_id = 1 AND taggings.taggable_type = 'Thing') 
+ Tag Update (0.000111) UPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 1) 
+ Tag Update (0.000093) UPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 1) 
+ Tagging Destroy (0.000096)  DELETE FROM taggings
+ WHERE "id" = 1
+
+ Tag Update (0.000095) UPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 4) 
+ Tag Update (0.000092) UPDATE tags SET "taggings_count" = "taggings_count" - 1 WHERE ("id" = 4) 
+ Tagging Destroy (0.000088)  DELETE FROM taggings
+ WHERE "id" = 2
+
+ Tag Load (0.000196) SELECT * FROM tags WHERE (tags."name" = 'not green') LIMIT 1
+ Tagging Create (0.000163) INSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(4, 'Thing', 1, NULL)
+ Tag Load (0.000240) SELECT * FROM tags WHERE (tags."id" = 4) 
+ Tag Update (0.000105) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 4) 
+ Tag Update (0.000097) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 4) 
+ Tag Load (0.000217) SELECT * FROM tags WHERE (tags."name" = 'animal') LIMIT 1
+ Tagging Create (0.000175) INSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(1, 'Thing', 1, NULL)
+ Tag Load (0.000225) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Update (0.000102) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 1) 
+ Tag Update (0.000093) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 1) 
+ Tag Load (0.000186) SELECT * FROM tags WHERE (tags."name" = 'favorite') LIMIT 1
+ Tagging Create (0.000114) INSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(5, 'Thing', 1, NULL)
+ Tag Load (0.000177) SELECT * FROM tags WHERE (tags."id" = 5) 
+ Tag Update (0.000097) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) 
+ Tag Update (0.000091) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) 
+ Tag Load (0.000787) SELECT tags.* FROM tags INNER JOIN taggings ON tags.id = taggings.tag_id WHERE ((taggings.taggable_type = 'Thing') AND (taggings.taggable_id = 1)) ORDER BY name asc
+ Tag Load (0.000196) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Load (0.000176) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Load (0.000174) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Load (0.000208) SELECT * FROM tags WHERE (tags."id" = 5) 
+ Tagging Load (0.000101) SELECT * FROM taggings WHERE (taggings.tag_id = 5) 
+ Thing Load (0.000155) SELECT * FROM things WHERE (things."id" = 1) 
+ Tagging Create (0.000130) INSERT INTO taggings ("tag_id", "taggable_type", "taggable_id", "user_id") VALUES(5, 'Thing', 1, NULL)
+ Tag Load (0.000187) SELECT * FROM tags WHERE (tags."id" = 5) 
+ Tag Update (0.000100) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) 
+ Tag Update (0.000093) UPDATE tags SET "taggings_count" = "taggings_count" + 1 WHERE ("id" = 5) 
+ Tagging Load (0.000212) SELECT * FROM taggings WHERE (taggings.tag_id = 5) 
+ Thing Load (0.000158) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000169) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000189) SELECT * FROM things WHERE (things."id" = 2) 
+ Tag Load (0.000175) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tagging Load (0.000343) SELECT * FROM taggings WHERE (taggings.tag_id = 1) 
+ Thing Load (0.000282) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000176) SELECT * FROM things WHERE (things."id" = 2) 
+ Tag Load (0.000228) SELECT * FROM tags WHERE (tags."id" = 2) 
+ Tagging Load (0.000357) SELECT * FROM taggings WHERE (taggings.tag_id = 2) 
+ Thing Load (0.000180) SELECT * FROM things WHERE (things."id" = 3) 
+ Thing Load (0.000172) SELECT * FROM things WHERE (things."id" = 4) 
+ Tagging Load (0.000268) SELECT * FROM taggings WHERE (taggings."id" = 1) 
+ Tagging Load (0.000233) SELECT * FROM taggings WHERE (taggings."id" = 3) 
+ Tag Load (0.000204) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tagging Load (0.000623) SELECT * FROM taggings WHERE (taggings.tag_id = 1) 
+ Tagging Load (0.000215) SELECT * FROM taggings WHERE (taggings."id" = 5) 
+ Tagging Load (0.000207) SELECT * FROM taggings WHERE (taggings."id" = 7) 
+ Tag Load (0.000195) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Load (0.000344) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tagging Load (0.000212) SELECT * FROM taggings WHERE (taggings."id" = 1) 
+ Tag Load (0.000175) SELECT * FROM tags WHERE (tags."id" = 1) 
+ Tag Load (0.000180) SELECT * FROM tags WHERE (tags."id" = 2) 
+ Thing Load (0.000163) SELECT * FROM things WHERE (things."id" = 1) 
+ Tagging Load (0.000216) SELECT * FROM taggings WHERE (taggings."id" = 1) 
+ Thing Load (0.000168) SELECT * FROM things WHERE (things."id" = 1) 
+ Thing Load (0.000159) SELECT * FROM things WHERE (things."id" = 2) 
Please sign in to comment.
Something went wrong with that request. Please try again.