AuthLogic + PostgreSQL 8.4: persistence_token is defined as a string, then used as an integer

I am trying to integrate AuthLogic into my rails application, and I have followed an example that defines persistence_token as a string:

https://github.com/binarylogic/authlogic_example

However, when I run it with PostgreSQL 8.4 on the ubuntu desktop, I get the following error:

ActiveRecord::StatementInvalid in UsersController#index

PGError: ERROR:  operator does not exist: character varying = integer
LINE 1: ...* FROM "users" WHERE ("users"."persistence_token" = 21007622...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT * FROM "users" WHERE ("users"."persistence_token" = 2100762299)  LIMIT 1

I tried changing persistence_token to an integer, but then it seemed like other parts of AuthLogic did not update it.

I am sure this should be a common problem, but googling search is not very useful, any ideas how to solve this?

Ruby version: 1.8.7 Rails version: 2.3.5 AuthLogic version: 2.1.6

+3
2

, "persistence_token" nil. , . , - , authlogic.

+1

, persistence_token?

. SQL .

 WHERE ("users"."persistence_token" = cast(2100762299 as varchar))
 WHERE ("users"."persistence_token" = 2100762299::text)
 WHERE ("users"."persistence_token" = text(2100762299))
 WHERE ("users"."persistence_token" = 2100762299 || '')

. PostgreSQL , .

Ruby.

yournumber.to_s
0

Source: https://habr.com/ru/post/1777376/


All Articles