Created
March 23, 2020 00:40
-
-
Save mkllnk/326a806e6453dd668d86d60fe1a6bb79 to your computer and use it in GitHub Desktop.
Producer export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
producers = Enterprise.is_primary_producer.joins(:address).where(spree_addresses: {state_id: 1061493592}).map { |e| {id: e.id, name: e.name, contact: e.contact_name, phone: e.phone, email: e.email_address, properties: e.producer_properties.map(&:value).join("|")} } | |
CSV.open("producers.csv", "wb") { |csv| csv << producers.first.keys; producers.each { |p| csv << p.values } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment