Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- funz_id_with_title = []
- error_funz = []
- CSV.new(open('/Users/dan/Downloads/Funzing_Talks_-_title_changes.csv'), :headers => :first_row).each do |row|
- funz_id_with_title << row.to_hash
- end
- funz_ids = funz_id_with_title.map { |row| row['Id'] }
- all_funz = Funz.where(id: funz_ids)
- all_funz.find_each do |funz|
- begin
- puts "working on funz #{funz.id}"
- funz_find = (funz_id_with_title.find { |x| x['Id'] == f.id.to_s})
- funz_find["Title"].length > 53 ? error_funz << funz.id : funz.update_column(:title, funz_find["Title"])
- rescue => e
- error_funz << funz.id
- puts "ERROR: #{e} - #{funz.id}"
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement