1. Hạn chế việc sử dụng if else lồng nhau. Ở đầu function nên return các case sai sau đó mới viết logic cho function
Example:
# unless ids.blank?
# sql = "DELETE FROM links WHERE links.user_id = #{user_id.to_s} AND links.id IN (#{ids.to_s})"
# connection.execute(sql)
# end
return if ids.blank?
where('user_id = ? AND id IN (?)', user_id, ids).delete_all