Created
March 8, 2014 06:39
-
-
Save yangxing-star/9426385 to your computer and use it in GitHub Desktop.
给城市增加图片
This file contains hidden or 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
Dir.glob("/home/ubuntu/cities/*").each do |f| | |
city_id = File.basename(f, ".png") | |
c = City.find_by_id(city_id) | |
if c.nil? | |
puts "-"*80 | |
puts city_id | |
puts "-"*80 | |
else | |
if c.cover.nil? | |
c.create_cover(image: File.open(f)) if c.cover.try(:image).nil? | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment