Godwin
8 years ago
4 changed files with 22 additions and 17 deletions
@ -1,11 +1,5 @@ |
|||||
class AddCityIdToLocation < ActiveRecord::Migration |
class AddCityIdToLocation < ActiveRecord::Migration |
||||
def change |
def change |
||||
add_column :locations, :city_id, :integer |
add_column :locations, :city_id, :integer |
||||
|
|
||||
Location.all.each do |l| |
|
||||
city = City.search(([l.city, l.territory, l.country] - [nil, '']).join(', ')) |
|
||||
l.city_id = city.id |
|
||||
l.save! |
|
||||
end |
|
||||
end |
end |
||||
end |
end |
||||
|
@ -1,9 +1,4 @@ |
|||||
class AddSpanishCityTranslations < ActiveRecord::Migration |
class AddSpanishCityTranslations < ActiveRecord::Migration |
||||
def change |
def change |
||||
City.all.each do |c| |
|
||||
city = c.get_translation(:es) |
|
||||
c.set_column_for_locale(:city, :es, city, 0) unless city.blank? || city == c.get_column_for_locale(:city, :es) |
|
||||
c.save! |
|
||||
end |
|
||||
end |
end |
||||
end |
end |
||||
|
Loading…
Reference in new issue