Reputation: 7230
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?
Upvotes: 10
Views: 3304
Reputation: 21
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
Upvotes: 1
Reputation: 11
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
Upvotes: 1
Reputation: 1409
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.
Upvotes: 25