spree-contrib / spree_globalize

Adds support for model translations (multi-language stores) using Globalize gem
https://spreecommerce.org
BSD 3-Clause "New" or "Revised" License
24 stars 102 forks source link

undefined method `translated_attribute_names' for #<Class:0x00007fb075953c60> #83

Open poudelprakash opened 3 years ago

poudelprakash commented 3 years ago

Getting folllowing error with latest version of thsis library, Url:http://localhost:3000/admin/stores/1/translations

Showing /Users/prakash/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/bundler/gems/spree_globalize-5e2e8134c9f5/app/views/spree/admin/translations/_fields.html.erb where line #6 raised:

undefined method `translated_attribute_names' for

channainfo commented 3 years ago

@poudelprakash I had the same problem. I saw in this commit https://github.com/spree-contrib/spree_globalize/commit/253c308a24ada35e49f213cff08549242e415376#diff-bfcf2ccfee02d99bd3b0b4932ca981983bf2a6edd40ebbead62e29c3b68649e2 the store_decorator was deleted. it raised error because Store model no longer has translated_attribute_names.

After putting this back

module Spree::StoreDecorator    
  def self.prepended(base)  
    base.translates :name, :meta_description, :meta_keywords, :seo_title, fallbacks_for_empty_translations: true    
  end   

  Spree::Store.include SpreeGlobalize::Translatable 
end 

::Spree::Store.prepend(Spree::StoreDecorator)

it works.

Store translation might be removed in favor of the default locale in the store model. For temporary fix you just need to add decorator to the store.