views:

263

answers:

1
+1  Q: 

globalize2 problem

Hi all. I have strange globalize2 problem. I'm trying to use globalize 2 and acts_as_textiled and acts_as_commentable. For example - lets we have Post model, that acts_as_commentable. From console

p = Post.find 1
c = p.comments.find 1

works fine, but in browser - nothing displayed

Similar, when Post contains

acts_as_textiled :body

from console body is containing correct data, but in browser i see nothing :(

Any ideas how to correct it?

Upd: "nothing displayed" means, that for code like

class Post < ActiveRecord::Base
translates :title, :body
acts_as_textiled  :body
end

on access to Post.body i've got nil, but on disabled globalize2 or acts_as_textiled body returns his value. I've tried with different locales - the same result.

A: 

Have you performed the necessary migrations? For localised content you should remove the localised fields in the main table (posts) and create a table for the localisations, like this:

create_table "post_translations", :force => true do |t|
  t.string  "locale"
  t.integer "product_id"
  t.string  "title"
  t.text    "body"
end

Just guessing here :)

nutsmuggler
Of course - all migrations was performed and fields removed. i've received recommendation to use this code to solve problem - http://gist.github.com/169709
Alexey Poimtsev