You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
default_scope { joins('INNER JOIN foobars ON foobars.id = versions.item_id') }
calling version.next gives me:
PG::AmbiguousColumn: ERROR: column reference "created_at" is ambiguous
LINE 1: ...e" = 'Foobar' AND "versions"."item_id" = 13808 AND (created_at...
^
: SELECT "versions".* FROM "versions" INNER JOIN foobars ON foobars.id = versions.item_id WHERE "versions"."item_type" = 'Foobar' AND "versions"."item_id" = 13808 AND (created_at > '2013-11-04 22:07:37.808161') ORDER BY created_at ASC LIMIT 1
The foobars table also has a created_at column that's colliding with the version created_at.
Using paper_trail sort of negates the necessity of a created_at column in my foobars table, but thought I'd report my findings anyhow.
The text was updated successfully, but these errors were encountered:
@kevinsu22 - Good to know. I think I have a fairly straightforward fix, explicitly declaring the table name in these scopes should alleviate the problem. That being said I'm trying to create a failing test for this to rectify. Where do you have this default_scope declared? Is this on your PaperTrail initializer within the PaperTrail::Version class?
Looks like I can reproduce it that way but am having trouble adding some sort of custom scope method using the joins operative that allows me to reproduce a similar error. I'll keep playing with it and see if I can figure something out unless you have a good idea on how to provide a failing test or spec.
@batter - I have it declared in the initializer. Any difference between having this sort of stuff in the initializer vs the class? (Other than having to restart my server every time i change something)
The title says it all!
I have a default scope like this:
calling version.next gives me:
The foobars table also has a created_at column that's colliding with the version created_at.
Using paper_trail sort of negates the necessity of a created_at column in my foobars table, but thought I'd report my findings anyhow.
The text was updated successfully, but these errors were encountered: