svenfuchs/globalize3 — Issue #86: Update resource fails
Author: togg
Created: 2011-12-11 00:11:01+00:00
State: open

I want to create translations for my model which works on creation (no matter if default language or other), but it fails on the update. Do I need to put some configure magic etc. in my controller to make it work or is this a bug related to Rails 3.1.3?

Using the latest GIT revision of globalize3.

Thanks a lot,
Sebastian

Loading development environment (Rails 3.1.3)
irb(main):001:0> I18n.locale
=> :en
irb(main):002:0> prod = Product.first
Product Load (0.3ms) SELECT "products".* FROM "products" LIMIT 1
=> #, recurring_cost: nil, recurring_period: 0, available_on: nil, removed_on: nil, can_be_part: false, individual_sale: true, created_at: "2011-12-10 20:25:29", updated_at: "2011-12-10 20:25:29">
irb(main):003:0> prod.name
Product::Translation Load (0.2ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."product_id" = 1
=> "Domain (.com)"
irb(main):004:0> I18n.locale = :de
=> :de
irb(main):005:0> prod.name
=> "Domain (.com)"
irb(main):006:0> prod.name = "Domäne"
=> "Domäne"
irb(main):007:0> prod.save
Product::Translation Load (0.2ms) SELECT "product_translations".* FROM "product_translations" WHERE "product_translations"."locale" = 'de' AND "product_translations"."name" = 'Domäne' LIMIT 1
(0.1ms) UPDATE "products" SET "name" = 'Domäne', "updated_at" = '2011-12-11 00:03:02.011461' WHERE "products"."id" = 1
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: name: UPDATE "products" SET "name" = 'Domäne', "updated_at" = '2011-12-11 00:03:02.011461' WHERE "products"."id" = 1
from /home/togg/.gem/ruby/1.8/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:91:in `initialize'
from /home/togg/.gem/ruby/1.8/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:91:in `new'
from /home/togg/.gem/ruby/1.8/gems/sqlite3-1.3.5/lib/sqlite3/database.rb:91:in `prepare'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:227:in `exec_query'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:244:in `log'
from /home/togg/.gem/ruby/1.8/gems/activesupport-3.1.3/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract_adapter.rb:239:in `log'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:223:in `exec_query'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/sqlite_adapter.rb:249:in `exec_update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:96:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/persistence.rb:305:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/locking/optimistic.rb:84:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/attribute_methods/dirty.rb:74:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/timestamp.rb:64:in `update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/callbacks.rb:272:in `update'
... 6 levels...
from /home/togg/.gem/ruby/1.8/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:399:in `_run_save_callbacks'
from /home/togg/.gem/ruby/1.8/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `send'
from /home/togg/.gem/ruby/1.8/gems/activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/callbacks.rb:264:in `create_or_update'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/persistence.rb:37:in `save'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/validations.rb:50:in `save'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/attribute_methods/dirty.rb:22:in `save'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `save'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:208:in `transaction'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:241:in `save'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
from /home/togg/.gem/ruby/1.8/gems/activerecord-3.1.3/lib/active_record/transactions.rb:240:in `save'
from (irb):7irb(main):008:0>