datocms / ruby-datocms-client

Ruby client for the DatoCMS API.
https://www.datocms.com/docs/content-management-api/using-the-ruby-client
MIT License
20 stars 14 forks source link

When trying to import data from module with some blank fields in records I get to_hash errors #16

Closed clockshark closed 4 years ago

clockshark commented 4 years ago

Fetching content from DatoCMS... Traceback (most recent call last): 12: from C:/Ruby26-x64/bin/dato:23:in

' 11: from C:/Ruby26-x64/bin/dato:23:in load' 10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/exe/dato:10:in<top (required)>' 9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in start' 8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:indispatch' 7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in invoke_command' 6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:inrun' 5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/lib/dato/cli.rb:47:in dump' 4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/lib/dato/dump/runner.rb:25:inrun' 3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/lib/dato/dump/runner.rb:25:in new' 2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/lib/dato/dump/dsl/root.rb:25:ininitialize' 1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/dato-0.7.5/lib/dato/dump/dsl/root.rb:25:in eval' (eval):17:ininitialize': undefined method to_hash' for #<Array:0x000000000969be88> (NoMethodError) Did you mean? to_h

`# dato.config.rb

Create a YAML data file to store global data about the site

create_data_file "_data/settings.yml", :yaml, favicon_meta_tags: dato.site.favicon_meta_tags, footer: dato.setting.footerlinks.to_hash, header: dato.setting.headerlinks.to_hash, address: dato.setting.address, homefeatureblock: dato.home.feature_blocks.to_hash, homereviews: dato.home.reviews.to_hash, home: dato.home.to_hash,
tour: dato.tour.to_hash, pricing: dato.pricing.to_hash, privacy: dato.privacy.to_hash, download: dato.download.to_hash, contact: dato.contact.to_hash, employees: dato.employees.to_hash, global: dato.setting.to_hash`

The data model that is causing the problem is employees and it has some records with blank fields. I was able to fix this in other places using something like "quote2: feature.quote2 ? feature.quote2.to_hash: '' but that only worked with nested data blocks.

matjack1 commented 4 years ago

hello @clockshark we sorted out the issue in Community, right?

I'm closing this for now, but if you still have issues please let me know!