Files
openfoodnetwork/lib/tasks/sample_data/addressing.rb
Maikel Linke c3029c612a Fix sample product creation and use bang methods
Mistakes like the missing fee when creating product distributions were
hidden, because I didn't use the bang methods to create records.
2019-02-05 16:23:17 +11:00

26 lines
488 B
Ruby

module Addressing
private
def address(string)
state = country.states.first
parts = string.split(", ")
Spree::Address.new(
address1: parts[0],
city: parts[1],
zipcode: parts[2],
state: state,
country: country
)
end
def zone
zone = Spree::Zone.find_or_create_by_name!("Australia")
zone.members.create!(zonable: country)
zone
end
def country
Spree::Country.find_by_iso(ENV.fetch('DEFAULT_COUNTRY_CODE'))
end
end