From 285119a5f37a27de89cf40399b77c350cc7716f9 Mon Sep 17 00:00:00 2001 From: Fu Matthew Date: Mon, 4 Mar 2013 19:29:45 +0800 Subject: [PATCH] fix for multi select cates and tags --- app/controllers/admin/page_parts_controller.rb | 2 +- app/controllers/default_widget_controller.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/page_parts_controller.rb b/app/controllers/admin/page_parts_controller.rb index fea1bf3f..4f72f97e 100644 --- a/app/controllers/admin/page_parts_controller.rb +++ b/app/controllers/admin/page_parts_controller.rb @@ -73,7 +73,7 @@ class Admin::PagePartsController < ApplicationController params[:page_part][:category] = [] end - params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} + params[:page_part][:widget_field].each{|t| t[2] = (t[2]=="true" ? true : false )} if !params[:page_part][:widget_field].blank? if @part.update_attributes(params[:page_part]) set_children_sub_menu(@part) if @part.public_r_tag && @part.public_r_tag.eql?('sub_menu') diff --git a/app/controllers/default_widget_controller.rb b/app/controllers/default_widget_controller.rb index 686a0316..e938ca45 100644 --- a/app/controllers/default_widget_controller.rb +++ b/app/controllers/default_widget_controller.rb @@ -20,13 +20,13 @@ class DefaultWidgetController< OrbitWidgetController if params["category_id"].blank? result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).entries.collect{|t| t.id}}.flatten else - result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:category_id=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten + result_ids = @tags.collect{|tag| tag.send(ori_class_name.downcase.pluralize).where(:category_id.in=>params["category_id"]).available_for_lang(I18n.locale).can_display.collect{|t| t.id}}.flatten end result = eval("#{ori_class_name}.where(:id=>result_ids)") elsif params["category_id"].blank? result = eval(@default_widget["query"]) else - result = eval("#{ori_class_name}.where(:category_id=>params['category_id'])") + result = eval("#{ori_class_name}.where(:category_id.in=>params['category_id'])") end result.available_for_lang(I18n.locale).can_display end