0
3 개의 편집본 (각 언어마다 하나씩)이 있습니다. 나중에 확인하면 텍스트가 DB에 삽입되지 않습니다. (나는 같은 텍스트를 3 번 얻는다).Globalize3에서 같은 언어로 설정
이것은 ingredients_category의 컨트롤러에 있으며 여기에서는 각 삽입 또는 업데이트 후에 update_other_locals_for를 호출합니다.이 정보는 괜찮습니다.
after_filter lambda { |controller| controller.update_other_locals_for(@ingredient_category) }, :only => [:create, :update]
이
내가 디버깅있을 때 나는이 볼 업데이트 라인이 박히는하고 올바른 텍스트는 그 시점지고 있지만available_locals.each do |available_locale|
I18n.locale = available_locale
params_object = "#{available_locale}_" + item.class.to_s.underscore.downcase
if params[params_object.to_sym].present?
item.update_attributes(params[params_object.to_sym])
end
end
호출되는와 ApplicationController의 코드입니다 질의 :
AND "ingredient_category_translations"."locale" = 'en'
:
Started PUT "/ingredient_categories/4" for 127.0.0.1 at 2013-06-20 21:58:34 +0200
Processing by IngredientCategoriesController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"aZFuv8v19oZcBkDmUzRzNyMUhBXnL5X0WvSyxNZhEuQ=", "ingredient_category"=>{"name"=>"Dutch"}, "en_ingredient_category"=>{"name"=>"English"}, "fr_ingredient_category"=>{"name"=>"French"}, "id"=>"4"}
Shop Load (0.8ms) SELECT "shops".* FROM "shops" WHERE "shops"."subdomain" = '' LIMIT 1
User Load (1.0ms) SELECT "users".* FROM "users" WHERE "users"."id" = 27 LIMIT 1
IngredientCategory Load (0.5ms) SELECT "ingredient_categories".* FROM "ingredient_categories" WHERE "ingredient_categories"."id" = ? LIMIT 1 [["id", "4"]]
CACHE (0.1ms) SELECT "ingredient_categories".* FROM "ingredient_categories" WHERE "ingredient_categories"."id" = ? LIMIT 1 [["id", "4"]]
(0.3ms) begin transaction
IngredientCategory::Translation Load (0.6ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."ingredient_category_id" = 4
(0.5ms) UPDATE "ingredient_categories" SET "updated_at" = '2013-06-20 19:58:34.880306' WHERE "ingredient_categories"."id" = 4
SQL (3.2ms) INSERT INTO "ingredient_category_translations" ("created_at", "ingredient_category_id", "locale", "name", "updated_at") VALUES (?, ?, ?, ?, ?) [["created_at", Thu, 20 Jun 2013 21:58:34 CEST +02:00], ["ingredient_category_id", 4], ["locale", "en"], ["name", nil], ["updated_at", Thu, 20 Jun 2013 21:58:34 CEST +02:00]]
IngredientCategory::Translation Load (0.5ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."ingredient_category_id" = 4 AND "ingredient_category_translations"."locale" = 'en' LIMIT 1
(0.7ms) UPDATE "ingredient_category_translations" SET "name" = 'Dutch', "updated_at" = '2013-06-20 19:58:34.918413' WHERE "ingredient_category_translations"."id" = 31
IngredientCategory::Translation Load (0.4ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."id" = ? LIMIT 1 [["id", 31]]
(2.2ms) commit transaction
Redirected to http://127.0.0.1:3000/ingredient_categories
(0.3ms) begin transaction
(0.6ms) UPDATE "ingredient_categories" SET "updated_at" = '2013-06-20 20:00:23.273350' WHERE "ingredient_categories"."id" = 4
IngredientCategory::Translation Load (0.4ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."ingredient_category_id" = 4 AND "ingredient_category_translations"."locale" = 'en' LIMIT 1
(0.4ms) UPDATE "ingredient_category_translations" SET "name" = 'English', "updated_at" = '2013-06-20 20:00:23.294591' WHERE "ingredient_category_translations"."id" = 31
IngredientCategory::Translation Load (0.4ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."id" = ? LIMIT 1 [["id", 31]]
(3.2ms) commit transaction
(0.3ms) begin transaction
(0.5ms) UPDATE "ingredient_categories" SET "updated_at" = '2013-06-20 20:01:19.871801' WHERE "ingredient_categories"."id" = 4
IngredientCategory::Translation Load (0.6ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."ingredient_category_id" = 4 AND "ingredient_category_translations"."locale" = 'en' LIMIT 1
(0.4ms) UPDATE "ingredient_category_translations" SET "name" = 'French', "updated_at" = '2013-06-20 20:01:19.892798' WHERE "ingredient_category_translations"."id" = 31
IngredientCategory::Translation Load (0.4ms) SELECT "ingredient_category_translations".* FROM "ingredient_category_translations" WHERE "ingredient_category_translations"."id" = ? LIMIT 1 [["id", 31]]
(1.1ms) commit transaction
Completed 302 Found in 187809ms (ActiveRecord: 19.2ms)
나는 이것을 발견
모든 업데이트. 해당 언어를 설정하지 않는 이유는 무엇입니까?