Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A fix for error "Mysql2::Error: Table 'transl_development.translations' doesn't exist: SHOW FIELDS FROM translations" #20

Closed
wants to merge 1 commit into from

Conversation

martinsp
Copy link

Using Rails version 3.1.3 (but i think, it could apply for 3.1.x)

Steps to reproduce:

  1. create new rails app
  2. create translation model
  3. add config/initializers/locale.rb file with required configuration
  4. run rake db:migrate (the exception is thrown)

I have narrowed it down to this commit in rails: rails/rails@c19bd4f#activerecord/lib/active_record/railtie.rb

During initialization of ActiveRecord it tests translation for 'activerecord.attributes' and 'activerecord.models'
In the described scenario migrations for Translation model has not been run yet, so table is missing and exception is thrown.

@fred
Copy link

fred commented Jan 8, 2012

svenfuchs, could you have a look and merge Martin's patch?
I have the exact same issue and his patch fixes it.

@jfirebaugh
Copy link

+1 on fixing this.

However, @martinsp, could you please use a guard clause rather than unless/else?

@kikorb
Copy link

kikorb commented Apr 9, 2012

if Translation.table_exists?
I18n.backend = I18n::Backend::ActiveRecord.new

I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
end

@reggieb
Copy link

reggieb commented Dec 12, 2012

I get class Translation doesn't exist errors with kikorb's fix. However, a slight modification gets it to work nicely.

require 'i18n/backend/active_record'

Translation  = I18n::Backend::ActiveRecord::Translation

if Translation.table_exists?
  I18n.backend = I18n::Backend::ActiveRecord.new

  I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Memoize)
  I18n::Backend::ActiveRecord.send(:include, I18n::Backend::Flatten)
  I18n::Backend::Simple.send(:include, I18n::Backend::Memoize)
  I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)

  I18n.backend = I18n::Backend::Chain.new(I18n::Backend::Simple.new, I18n.backend)
end 

This is only an issue during installation when the code is added but the translations table has not been created yet. I think all that is needed is to use the code above in the README as the example of the code to be used in the initializer.

@svenfuchs
Copy link
Owner

any of you guys interested in taking this repo over? i don't use it myself anymore and i don't really have time either.

drop me an email with your github handle and rubygems email address and i'll add you :)

@kalinchuk
Copy link

Anything on this pull request?

@timfjord
Copy link
Collaborator

To prevent this issue just use instructions from README

@timfjord timfjord closed this Mar 25, 2016
@timfjord timfjord mentioned this pull request Mar 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants