From 96455f31e183a1c309c10f13e6688cd5e36d6400 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Mon, 18 Feb 2013 19:04:04 +0800 Subject: [PATCH] deliver app config. fix wrong value cause error for default widget --- app/helpers/admin/page_parts_helper.rb | 11 +++++++++-- config/mongoid.yml | 4 ++-- lib/tasks/migrate.rake | 5 +++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/helpers/admin/page_parts_helper.rb b/app/helpers/admin/page_parts_helper.rb index 5eeb553d..898b139e 100644 --- a/app/helpers/admin/page_parts_helper.rb +++ b/app/helpers/admin/page_parts_helper.rb @@ -25,8 +25,15 @@ module Admin::PagePartsHelper local_item = @part if local_item.nil? && @part local_item = @page if local_item.nil? && @page res = '' - choosen_value = prefill_value || local_item[:widget_field][i][0] - choosen_field_is_link = (@module_app.widget_fields.select{|t| t[0].to_s==choosen_value}.first)[2]==:link + + choosen_value = prefill_value || (local_item[:widget_field][i][0] rescue nil) + + if choosen_value + choosen_field_is_link = (@module_app.widget_fields.select{|t| t[0].to_s==choosen_value}.first)[2]==:link + else + choosen_field_is_link = false + end + if choosen_field_is_link value = case local_item diff --git a/config/mongoid.yml b/config/mongoid.yml index a809bc06..2fa55a36 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -8,10 +8,10 @@ defaults: &defaults development: <<: *defaults - database: demo_site_development + database: test_site test: <<: *defaults - database: demo_site_test + database: test_site # set these environment variables on your prod server production: diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 6582fa2a..f3b16f16 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -448,14 +448,15 @@ namespace :migrate do PagePart.all.each do |pp| pp[:backup_module_app_key] = (pp.module_app ? pp.module_app.key : nil) + puts pp.id pp.save - puts pp.inspect + # puts pp.inspect end Page.all.each do |page| page[:backup_module_app_key] = (page.module_app ? page.module_app.key : nil) page.save - puts page.inspect + # puts page.inspect end end