mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-11 23:17:48 +00:00
Adding addresses to existing groups and make them changable
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user