Replaced find_by_sql with AR query