Adding addresses to existing groups and make them changable

This commit is contained in:
Maikel Linke
2015-01-22 12:10:54 +11:00
parent 0d9a0919e5
commit 87b092fdf7
3 changed files with 19 additions and 3 deletions

View File

@@ -0,0 +1,14 @@
class AddAddressInstancesToExistingEnterpriseGroups < ActiveRecord::Migration
def change
country = Spree::Country.find_by_name(ENV['DEFAULT_COUNTRY'])
state = country.states.first
EnterpriseGroup.all.each do |g|
if g.address.present? then
next
end
address = Spree::Address.new(firstname: 'unused', lastname: 'unused', address1: 'undefined', city: 'undefined', zipcode: 'undefined', state: state, country: country, phone: 'undefined')
g.address = address
g.save
end
end
end