0
我想使用活動記錄來做這個查詢,所以我可以使查詢安全的注入。 DB是Postgresql。 Ruby on Rails的3.2.11有兩個表加入和條件的有效記錄查詢
def find_possible_duplicates(last_name, date_of_birth, organisation_id)
find_by_sql('select c.* from clients c' +
' join locations l on c.location_id = l.id' +
" where c.last_name ILIKE #{last_name}" +
" and c.date_of_birth = #{date_of_birth}" +
" and l.organisation_id = #{organisation_id}"
end
任何幫助表示讚賞