Can't handle UUIDs
pachacamac opened this issue · 2 comments
pachacamac commented
I tried to use UUIDs for my taggable object resulting in
ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "b8cc337e-8535-4115-b782-e261c4cfa32a"
: SELECT "gutentag_tags".* FROM "gutentag_tags" INNER JOIN "gutentag_taggings" ON "gutentag_tags"."id" = "gutentag_taggings"."tag_id" WHERE "gutentag_taggings"."taggable_id" = $1 AND "gutentag_taggings"."taggable_type" = $2
trying to debug it now. found the problem.
Had to modify the generated migration from
create_table :gutentag_taggings do |t|
t.integer :tag_id, null: false
t.integer :taggable_id, null: false
t.string :taggable_type, null: false
t.timestamps null: false
end
to
create_table :gutentag_taggings do |t|
t.integer :tag_id, null: false
t.uuid :taggable_id, null: false
t.string :taggable_type, null: false
t.timestamps null: false
end
pat commented
Ah, good to know :) I'll have to make a note for this in the documentation (or you're welcome to submit a PR if you'd like!)
pachacamac commented
PR is easier said than done :) I wouldn't want to overwrite the default behavior for Integer IDs and can't really think of a way to conveniently make it type-polymorphic since things become a bit harder once you want to tag multiple models where some use UUIDs and some Interger IDs...
Thought I'd still leave the issue here so others in the future might get some help out of it. 🤞