Skip to content
This repository has been archived by the owner on Nov 12, 2024. It is now read-only.

ItemsRepo#build_cache! is flawed when combined with I18n.with_locale #4

Closed
ahoward opened this issue Sep 13, 2016 · 2 comments
Closed

Comments

@ahoward
Copy link

ahoward commented Sep 13, 2016

tl;dr; if you switch locales the cache is the wrong locale.

I18n.enforce_available_locales = false

dato.available_locales.each do |locale|

  directory "data/dato/#{locale}" do
    I18n.with_locale(locale) do

      dato.send(:build_cache!)  # without this the cache will contain data for the wrong locale ;-/

      create_data_file "site.yml", :yaml, dato.site.to_hash

      dato.item_types.each do |item_type|
        create_data_file "#{item_type.api_key}.yml", :yaml, 
          dato.items_of_type(item_type).map(&:to_hash)
      end
    end
  end

end
@stefanoverna
Copy link
Member

Thanks @ahoward for the report.. fixed by 1c6eb0c, and released as v0.1.27

@stefanoverna
Copy link
Member

The same commit also fixes the situation where an Item Type has a field called slug. In this case, the gem returns the directly the field value, and does not generate a slug on its own.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants