开发者

Globalize3 english translations in posts or post_translations?

开发者 https://www.devze.com 2023-02-16 23:34 出处:网络
I have an existing site with fields in post.title and post.body. After I installed Globalize3, post.title returns blank. Is there a way that I don\'t need to migrate the existing information to开发者_

I have an existing site with fields in post.title and post.body. After I installed Globalize3, post.title returns blank. Is there a way that I don't need to migrate the existing information to开发者_运维知识库 post_translations?


You can migrate this data by defining it to migrate the data when creating the translations table in the first place.

eg.

class TranslatePosts < ActiveRecord::Migration
  def self.up
    Post.create_translation_table!({
      :title => :string,
      :text => :text
    }, {
      :migrate_data => true
    })
  end
  def self.down
    Post.drop_translation_table! :migrate_data => true
  end
end

You will have to drop the existing posts translations table beforehand.


Hey I was having same issue. Found that for :migrate_data => true to work you need to have your globalize3 version 0.1.0.beta otherwise it won't work.

You can checkout this - https://github.com/svenfuchs/globalize3/issues/45

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号