Skip to content

Instantly share code, notes, and snippets.

@yangxing-star
Created March 8, 2014 06:39
Show Gist options
  • Save yangxing-star/9426385 to your computer and use it in GitHub Desktop.
Save yangxing-star/9426385 to your computer and use it in GitHub Desktop.
给城市增加图片
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