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

problems with uuid indexes #122

Open
alec-c4 opened this issue Dec 16, 2020 · 1 comment
Open

problems with uuid indexes #122

alec-c4 opened this issue Dec 16, 2020 · 1 comment

Comments

@alec-c4
Copy link

alec-c4 commented Dec 16, 2020

Hey!
I have the following models

class User < ApplicationRecord
  acts_as_reader
end
class Conversation < ApplicationRecord
  has_many :comments, dependent: :destroy, as: :commentable
  acts_as_readable on: :created_at
end

for both User and Conversation, I use UUID-indexes, but for

Conversation.first.mark_as_read! for: current_user

I see error

ActiveRecord::StatementInvalid: PG::InvalidTextRepresentation: ERROR: invalid input syntax for type uuid: "80"

What's wrong with code?

@fatkodima
Copy link
Contributor

It's a bit late, but I was able to reproduce this.
Can you change the generated migration file to

- t.references :readable, polymorphic: { null: false }
+ t.references :readable, polymorphic: { null: false }, type: :uuid
- t.references :reader,   polymorphic: { null: false }
+ t.references :reader,   polymorphic: { null: false }, type: :uuid

and verify if it is working now?

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