diff --git a/app/controllers/e_papers_controller.rb b/app/controllers/e_papers_controller.rb index 71da12c..24f1ab7 100644 --- a/app/controllers/e_papers_controller.rb +++ b/app/controllers/e_papers_controller.rb @@ -78,7 +78,7 @@ class EPapersController < ApplicationController end data = [] papers.each do |category, topics| - topics_data = topics.collect do |topic| + topics_data = Array(topics).compact.collect do |topic| { "title" => topic.title, "link_to_show" => OrbitHelper.url_to_show(topic.to_param), @@ -117,7 +117,7 @@ class EPapersController < ApplicationController def criteria_list params = OrbitHelper.params criterias = PaperCriteria.all.desc(:start_date).limit(OrbitHelper.widget_data_count) - data = criterias.collect do |criteria| + data = Array(criterias).compact.collect do |criteria| { "title" => criteria.title, "description" => criteria.description, @@ -136,14 +136,14 @@ class EPapersController < ApplicationController def category_wise_articles topics = EPaperTopic.filter_by_widget_categories.desc(:period) - data = topics.collect do |topic| + data = Array(topics).compact.collect do |topic| { "title" => topic.title, "link_to_show" => OrbitHelper.widget_item_url(topic.to_param), "description" => topic.description, "img_url" => topic.image.url, "img_url_thumb" => topic.image.thumb.url, - "category" => topic.category.title, + "category" => (topic.category.title rescue nil), "link_to_show_wise" => OrbitHelper.widget_more_url + "/" + topic.to_param } end @@ -160,18 +160,18 @@ class EPapersController < ApplicationController papers = criteria.epaper_topics.group_by(&:category) data = [] papers.each do |category, topics| - topics_data = topics.collect do |topic| + topics_data = Array(topics).compact.collect do |topic| { "title" => topic.title, "link_to_show" => OrbitHelper.widget_item_url(topic.to_param), "description" => topic.description, "img_url" => topic.image.url, "img_url_thumb" => topic.image.thumb.url, - "category" => category.title + "category" => (category.title rescue nil) } end data << { - "category_title" => category.title, + "category_title" => (category.title rescue nil), "topics" => topics_data } end @@ -188,18 +188,18 @@ class EPapersController < ApplicationController papers = criteria.epaper_topics.group_by(&:category) data = [] papers.each do |category, topics| - topics_data = topics.collect do |topic| + topics_data = Array(topics).compact.collect do |topic| { "title" => topic.title, "link_to_show" => OrbitHelper.widget_item_url(topic.to_param), "description" => topic.description, "img_url" => topic.image.url, "img_url_thumb" => topic.image.thumb.url, - "category" => category.title + "category" => (category.title rescue nil) } end data << { - "category_title" => category.title, + "category_title" => (category.title rescue nil), "topics" => topics_data } end