I have a new rails engine and I want to use globalize3. I did this in my lib//engine.rb :
require 'globalize3'
module SimpleCms
class Engine < ::Rails::Engine
end
end
Now, I try to create a migration like this :
class CreatePages < ActiveRecord::Migration
def up
create_table :pages do |t|
t.string :path
t.timestamps
end
Page.create_translation_table! title: :string, body: :body
end
def down
drop_table :pages
Page.drop_translation_table!
end
end
And I have this error :
undefined method `create_translation_table!' for #<Class:0x00000001d5ca18>
I think the file 'lib/globalize/active_record/migration.rb' is not loaded.
Any solution?
You have to add
translates :attributename
to your Engine model file before you run the migration. (Replace :attributename with the attribute you want to have translated). That fixed it for me.
Try this
SimpleCms::Page.create_translation_table! title: :string, body: :body
but the foreign key will become simplecms_page_id
, I manually change it back to page_id
In my case, globilize
gem wasn't working correctly, because traco
gem was also in Gemfile. Removing traco
fixed the error. So I guess only using one of translation gems is allowed
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With