fix some error

This commit is contained in:
chiu 2020-03-24 23:01:49 +08:00
parent eb50bc6b49
commit b2089c26ca
1 changed files with 10 additions and 10 deletions

View File

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