ledermann / unread

Handle unread records and mark them as read with Ruby on Rails
MIT License
739 stars 121 forks source link

problems with uuid indexes #122

Open alec-c4 opened 3 years ago

alec-c4 commented 3 years ago

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 commented 3 years ago

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?