From 50813eb57d3e94f073ce89cc06450ea621930b3e Mon Sep 17 00:00:00 2001 From: Christophe Vilayphiou Date: Thu, 26 Jul 2012 03:47:14 +0800 Subject: [PATCH] Remove i18n_variable for page_content --- lib/tasks/migrate.rake | 15 +++++++++++++++ .../page_content/app/models/page_context.rb | 4 ++-- .../back_end/page_contexts/_form.html.erb | 6 +++--- .../back_end/page_contexts/_page_context.html.erb | 2 +- .../page_contexts/_view_page_context.html.erb | 2 +- .../back_end/page_contexts/show.html.erb | 4 ++-- .../front_end/page_contexts/index.html.erb | 4 ++-- 7 files changed, 26 insertions(+), 11 deletions(-) diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 485db8c8..da664bab 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -141,6 +141,21 @@ namespace :migrate do end p 'End NewsBulletinLink' + p '=====================================================' + p '=====================================================' + + p 'Start PageContext' + page_contexts = PageContext.admin_manager_all + i = 1 + page_contexts.each do |page_context| + p "#{i}/#{page_contexts.size} - #{page_context.id}" + context = I18nVariable.first(:conditions => {:language_value_id => page_context.id, :language_value_type => page_context.class}) + page_context.context_translations = {'en' => context['en'], 'zh_tw' => context['zh_tw']} if context + page_context.save(:validate => false) + i += 1 + end + p 'End PageContext' + end end diff --git a/vendor/built_in_modules/page_content/app/models/page_context.rb b/vendor/built_in_modules/page_content/app/models/page_context.rb index be60db27..7c9bde35 100644 --- a/vendor/built_in_modules/page_content/app/models/page_context.rb +++ b/vendor/built_in_modules/page_content/app/models/page_context.rb @@ -9,7 +9,7 @@ class PageContext is_impressionable :counter_cache => { :column_name => :view_count } - has_one :context, :class_name => "I18nVariable", :as => :language_value, :autosave => true, :dependent => :destroy + field :context, localize: true field :create_user_id field :update_user_id @@ -26,7 +26,7 @@ class PageContext ObjectAuthTitlesOptions = %W{Edit} def pp_object - page.i18n_variable[I18n.locale] + page.title end def is_top? diff --git a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb index 835b0511..f1dc0822 100644 --- a/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb +++ b/vendor/built_in_modules/page_content/app/views/panel/page_content/back_end/page_contexts/_form.html.erb @@ -6,7 +6,7 @@
<%= f.label :name %> - <%= @page_context.page.i18n_variable[I18n.locale] %> + <%= @page_context.page.title %>