spree-contrib / spree_static_content

Manage static pages for Spree Commerce.
http://guides.spreecommerce.org
BSD 3-Clause "New" or "Revised" License
217 stars 333 forks source link

Problem with Translations #237

Closed htorohn closed 6 years ago

htorohn commented 6 years ago

Hello,

i update by accident the gem and when running again the application I started to get the following error

undefined method `translates' for Spree::Page:Class Did you mean? transaction

After that I tried to uninstall and reinstall the gem, but getting the same error when running the migrations:

== 20171115044059 AddTranslationToSpreePages: migrating ======================= rails aborted! StandardError: An error has occurred, all later migrations canceled:

undefined method translates' for Spree::Page(Table doesn't exist):Class Did you mean? transaction /Users/toro/Documents/Desarrollo/myshop/db/migrate/20171115044059_add_translation_to_spree_pages.spree_static_content.rb:5:inup' /Users/toro/Documents/Desarrollo/myshop/bin/rails:9:in require' /Users/toro/Documents/Desarrollo/myshop/bin/rails:9:in<top (required)>' /Users/toro/Documents/Desarrollo/myshop/bin/spring:15:in <top (required)>' bin/rails:3:inload' bin/rails:3:in `

'

Caused by: NoMethodError: undefined method translates' for Spree::Page(Table doesn't exist):Class Did you mean? transaction /Users/toro/Documents/Desarrollo/myshop/db/migrate/20171115044059_add_translation_to_spree_pages.spree_static_content.rb:5:inup' /Users/toro/Documents/Desarrollo/myshop/bin/rails:9:in require' /Users/toro/Documents/Desarrollo/myshop/bin/rails:9:in<top (required)>' /Users/toro/Documents/Desarrollo/myshop/bin/spring:15:in <top (required)>' bin/rails:3:inload' bin/rails:3:in `

' Tasks: TOP => db:migrate (See full trace by running task with --trace)

Do you have any ideas on how to fix this?

Thanks in advance!

bbonislawski commented 6 years ago

Hello @htorohn , I'm really sorry that this happened. We merged support for page translations and now you need to require spree_i18n and spree_globalize in your Gemfile. I'm updating readme.

If you're using spree 3.2+ then you have to add

gem "spree_i18n", github: "spree-contrib/spree_i18n", branch: "master"
gem "spree_globalize", github: "spree-contrib/spree_globalize", ref: "master"

and when you use 3.1 add:

gem "spree_i18n", github: "spree-contrib/spree_i18n", branch: "3-1-stable"
gem "spree_globalize", github: "spree-contrib/spree_globalize", ref: "master"

Hopefully this will fix your issue. I'm waiting for your response

htorohn commented 6 years ago

Hi @bbonislawski, I included spree_globalize as you suggested (spree_i18n was already included) and it worked!!

Thank you very much for your support.

Just to add a little information, in order to install properly the spree_globalize, I had to add this 3 lines to my Gemfile:

gem 'globalize', git: 'https://github.com/globalize/globalize' gem 'activemodel-serializers-xml' gem "spree_globalize", github: "spree-contrib/spree_globalize", branch: "master"

And to reinstall spree_static_content I had to removed all previous migrations copied to the db folder, as they were interfering with spree_globalize migration installs