Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't handle UUIDs #57

Closed
pachacamac opened this issue Jul 18, 2018 · 2 comments
Closed

Can't handle UUIDs #57

pachacamac opened this issue Jul 18, 2018 · 2 comments

Comments

@pachacamac
Copy link

pachacamac commented Jul 18, 2018

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
Copy link
Owner

pat commented Jul 18, 2018

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
Copy link
Author

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. 🤞

@pat pat closed this as completed in a37c904 Sep 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants