Created
October 5, 2016 07:57
-
-
Save luciuschoi/827a3011b221425fe8ac48514945c7c6 to your computer and use it in GitHub Desktop.
trevari_import_passed_membership
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def import_passed_membership(csv_file="trevari_passed_membership.csv") | |
csv_data = open(csv_file) | |
csv_rows = CSV.parse(csv_data.read.force_encoding("utf-8"), { headers: true, | |
converters: :numeric, | |
header_converters: :symbol }) | |
csv_rows.each do |m| | |
p m | |
c = Club.find(m[3]) | |
# raise unless c | |
u = User.where(phone_number: m[1]).first | |
# raise unless u | |
c.applications.where(user_id: u.id, status: Application.statuses["입금 확인"]).first_or_create | |
c.memberships.where(user_id: u.id).first_or_create | |
u.add_role(:member) | |
end | |
end |
Author
luciuschoi
commented
Oct 5, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment