Created
June 29, 2012 07:18
-
-
Save sriedel/3016439 to your computer and use it in GitHub Desktop.
copy opt-out-urls from xml feed
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
file = File.readlines( "20120628T111327_1" ) | |
hash = {} | |
pairs = file.grep( /extid|opt_out_url/ ). | |
map { |e| e.gsub( /<.*?>/, '' ) }. | |
map(&:strip) | |
pairs.shift | |
pairs.each_slice( 2 ) { |e| hash[e[0].to_i] = e[1] } | |
hash.delete(0) | |
UserApplication.find( hash.keys ). | |
select { |e| e.opt_out_url.blank? }. | |
each do |e| | |
e.opt_out_url = hash[e.id] | |
e.save( :validate => false ) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment