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

Userid is coming as 0, 1, 2 etc #304

Open
brgcy opened this issue Apr 7, 2022 · 1 comment
Open

Userid is coming as 0, 1, 2 etc #304

brgcy opened this issue Apr 7, 2022 · 1 comment

Comments

@brgcy
Copy link

brgcy commented Apr 7, 2022

Hi Folks,

Thanks for creating this wonderful gem.
I am trying to use this gem and almost all my needs are working well.
However, I noticed that the user_id is coming as nil, 0, 1, 2, 3.... etc

See below:

> Impression.last
  Impression Load (1.6ms)  SELECT  "impressions".* FROM "impressions" ORDER BY 
"impressions"."id" DESC LIMIT $1 /*application:Foo*/  [["LIMIT", 1]]
=> #<Impression id: 2256, impressionable_type: "EditablePage", impressionable_id: 39, 
user_id: 5, controller_name: "blog_posts", action_name: "show", view_name: nil, 
request_hash: "fdcb03fdfd...", ip_address: "1xx.xx.xx.76", session_hash: "293e851aec2260bec0b556cf68080e04", 
message: "Getting foo blog post", referrer: "https://example.com/blog/?page=1", 
params: {"slug"=>"foo"}, created_at: "2022-04-07 11:49:33", updated_at: "2022-04-07 11:49:33">

How I am adding

def show
  @blog_post = BlogPost.find_by(slug: params[:slug])
  impressionist(@blog_post, "Hitting #{@blog_post.title}.")
  ...
end

Anything I am missing here?

After changing the migration to create ImpressionTable, I am getting following error:

PG::InvalidTextRepresentation: ERROR: invalid input syntax for type uuid: "0" : 
INSERT INTO "impressions" ("impressionable_type", "impressionable_id", "controller_name", 
"action_name", "request_hash", "ip_address", "session_hash", "message", "params", 
"created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) 
RETURNING "id" /*application:Foo,controller:blog_posts,action:show*/
@chpahlit
Copy link

Hey dont know if this is still helpful, as it seems for me you are working with uuids as primary ids.
I just changed in the migration table the user_id and the impressionable_id to strings like:

t.string :impressionable_id
t.string :user_id

that worked for me

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