I have an Active Record query that involves a JOIN using a SQL statement.
TableA.where(:b_id => "123")
.joins("INNER JOIN TableB ON column1='value1' AND column2 = TableB.id")
where column1 and column2 belong to TableA
The reason I have to use SQL is because I don't have a relationship defined between the two tables (for other reasons), and haven't found a way to specify a ON clause on columns, using Active Record JOIN
Since I don't have a relationship defined, I cannot use :includes and hence do not have access to TableB's columns in the results. Is there a way to get TableB's data by modifying the above query?