From 17ac564fbb634bb67f9c3d50e38256871291f1d9 Mon Sep 17 00:00:00 2001 From: chris Date: Wed, 6 Feb 2013 12:12:23 +0800 Subject: [PATCH] Fix sitemap nil Fix namespace of role in subrole --- app/controllers/admin/sub_roles_controller.rb | 2 +- app/models/item.rb | 4 ++-- lib/tasks/migrate.rake | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/sub_roles_controller.rb b/app/controllers/admin/sub_roles_controller.rb index e39f783d..f28149ea 100644 --- a/app/controllers/admin/sub_roles_controller.rb +++ b/app/controllers/admin/sub_roles_controller.rb @@ -1,4 +1,4 @@ -class Admin::SubRolesController < RolesController +class Admin::SubRolesController < Admin::RolesController end diff --git a/app/models/item.rb b/app/models/item.rb index a670435f..17880e4a 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -12,7 +12,7 @@ class Item field :enabled_for, :type => Array, :default => nil field :menu_enabled_for, :type => Array, :default => nil field :title, localize: true - field :sitemap_enabled, :type => Hash + field :sitemap_enabled, :type => Hash, :default => {} validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/ @@ -57,7 +57,7 @@ class Item end def show_in_sitemap_for(locale) - if sitemap_enabled && !sitemap_enabled[locale].blank? + if !sitemap_enabled.blank? && !sitemap_enabled[locale].blank? sitemap_enabled[locale].eql?('true') ? true : false else true diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 0c7d6148..bb92e72e 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -307,7 +307,7 @@ namespace :migrate do task :sitemap_i18n => :environment do Item.all.each do |item| - item.sitemap_enabled = item.sitemap_enabled ? {'en' => 'true', 'zh_tw' => 'true'} : nil + item.sitemap_enabled = item.sitemap_enabled ? {'en' => 'true', 'zh_tw' => 'true'} : {} item.save end end