fix default failed when cate or tags set to empty

This commit is contained in:
Fu Matthew 2013-03-05 11:48:20 +08:00
parent 285119a5f3
commit 626b2a7bca
1 changed files with 5 additions and 3 deletions

View File

@ -14,6 +14,9 @@ class DefaultWidgetController< OrbitWidgetController
ori_class_name = @default_widget["query"].split('.')[0]
result = nil
result_objects = nil
params["tag_id"] = [] if params["tag_id"]=="[]"
params["category_id"] = [] if params["category_id"]=="[]"
if !params["tag_id"].blank?
@tags = Tag.find(params["tag_id"]) rescue nil
result_ids = nil
@ -32,7 +35,6 @@ class DefaultWidgetController< OrbitWidgetController
end
def default_widget
if !params[:id].blank?
redirect_to eval("#{@page_part.module_app.widget_fields_link_method['title']['method']}('#{params[:id]}', {inner: #{params[:inner] || true}})")
else
@ -50,10 +52,10 @@ class DefaultWidgetController< OrbitWidgetController
@data_limit = @page_part.widget_data_count.is_a?(Fixnum) ? @page_part.widget_data_count : (@page_part.widget_data_count.to_i rescue 3)
end
if @paginate
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit)
@data = query_for_default_widget.includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
# @data = query_for_default_widget.limit(@data_limit).includes(@widget_image_field)
else
@data = eval(@default_widget["query"]).includes(@widget_image_field).page(params[:page_main]).per(@data_limit).desc(:created_at)
@data = query_for_default_widget.includes(@widget_image_field).desc(:created_at)
# @data = eval(@default_widget["query"]).limit(@data_limit).includes(@widget_image_field).desc(:created_at)
end
case params[:type]