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
ActiveRecord(?) adds aliases to queries to handle ambiguity when passing the query as a nested hash: Son.joins(:father).where(father: { age: [50, 51] }).ransack(father_name_eq: 'John')
throwing: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: invalid reference....
The workaround is to create an SQL query without the alias so Ransack can be joined: Son.joins(:father).where('fathers.age': [50,51]).ransack(father_name_eq: 'John')
Obviously, this is not a solution.
Need a way to handle aliases.
The text was updated successfully, but these errors were encountered:
Hi, this is not a solution, but another workaround for folks running in to this issue.
It works for me to use the nested hash syntax instead of the string syntax as long as the referenced name is the pluralized table name as opposed to the singular relationship name.
ActiveRecord(?) adds aliases to queries to handle ambiguity when passing the query as a nested hash:
Son.joins(:father).where(father: { age: [50, 51] }).ransack(father_name_eq: 'John')
throwing:
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: invalid reference....
The workaround is to create an SQL query without the alias so Ransack can be joined:
Son.joins(:father).where('fathers.age': [50,51]).ransack(father_name_eq: 'John')
Obviously, this is not a solution.
Need a way to handle aliases.
The text was updated successfully, but these errors were encountered: