Fix errors and deprecation warnings

@david-yz-liu  No, it was an error. This reason i removed this part was we don't need to convert variable `memberships` to an array, because when we call `memberships.each`, it will be converted to array automatically.