svenfuchs/globalize3 — Issue #75: Cannot fetch model after translating it via create_translation_table! migrate_data: true
Author: ncri
Created: 2011-10-20 06:54:16+00:00
State: open

I just translated a model called "Content". When I do Content.first I get a stack level too deep error as globalize seems to try to fetch the same translated instance over and over again:

```
Content.first
Content Load (0.8ms) SELECT "contents".* FROM "contents" LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.6ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.6ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.7ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.7ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.9ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.8ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.7ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.6ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.9ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.6ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.6ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
Content::Translation Load (0.5ms) SELECT "content_translations".* FROM "content_translations" WHERE "content_translations"."content_id" = 3
Content Load (0.5ms) SELECT "contents".* FROM "contents" WHERE "contents"."id" = 3 LIMIT 1
....
many more of the above
....
SystemStackError: stack level too deep
from /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/arel-2.2.1/lib/arel/visitors/to_sql.rb:100
```

Im using Rails 3.1.0 with Ruby 1.9.2-p290 and the latest globalize3 gem from github.