From c44b86f284c50addf136f375ea7cec7be75d31d9 Mon Sep 17 00:00:00 2001 From: rulingcom Date: Mon, 31 Jan 2011 10:57:41 +0800 Subject: [PATCH] fix bugs for i18n_variable in page and home --- app/models/home.rb | 2 +- app/models/item.rb | 2 +- app/views/admin/homes/_form.html.erb | 4 ++-- app/views/admin/pages/_form.html.erb | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/models/home.rb b/app/models/home.rb index 4f09596d..92a96118 100644 --- a/app/models/home.rb +++ b/app/models/home.rb @@ -6,5 +6,5 @@ class Home < Page def validates_presence_of_parent_id? false end - + end diff --git a/app/models/item.rb b/app/models/item.rb index 5ecd30cd..1f610f7e 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -60,7 +60,7 @@ class Item # Check if the page is home def is_home? - self.name.eql?('home') && self.parent_id.nil? + self.name.eql?('home') && (self.parent_id.nil? || self.parent_id.empty?) end # Build the url from the array of ancestors diff --git a/app/views/admin/homes/_form.html.erb b/app/views/admin/homes/_form.html.erb index c766bb1e..6ab0e382 100644 --- a/app/views/admin/homes/_form.html.erb +++ b/app/views/admin/homes/_form.html.erb @@ -9,8 +9,8 @@ <% @site_valid_locales.each do |locale| %>

- <%= label_tag "#{f}[title]", "#{t('admin.title')} #{locale}" %> - <%= text_field_tag "#{f}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :class => 'text' %> + <%= label_tag "home[title]", "#{t('admin.title')} #{locale}" %> + <%= text_field_tag "home[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :class => 'text' %>

<% end %> diff --git a/app/views/admin/pages/_form.html.erb b/app/views/admin/pages/_form.html.erb index f3e34e20..caf85e50 100644 --- a/app/views/admin/pages/_form.html.erb +++ b/app/views/admin/pages/_form.html.erb @@ -2,7 +2,7 @@

<%= f.label :name, t('admin.name') %> -<% if @page.parent_id.nil? %> +<% if @page.parent_id.nil? || @page.parent_id.empty? %> <%= f.text_field :name, :class => 'text', :value => 'home', :disabled => true %> <%= f.hidden_field :name, :value => 'home' %> <% else %> @@ -13,8 +13,8 @@ <% @site_valid_locales.each do |locale| %>

- <%= label_tag "#{f}[title]", "#{t('admin.title')} #{locale}" %> - <%= text_field_tag "#{f}[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :class => 'text' %> + <%= label_tag "page[title]", "#{t('admin.title')} #{locale}" %> + <%= text_field_tag "page[i18n_variable][#{locale}]", (@i18n_variable[locale] if @i18n_variable), :class => 'text' %>

<% end %>