Don't use find_by_sql, please try find(:department_id => @department_id.to_i), or find(:department_id => @department_id) directly.