From 4b2f23ca810061c468a0a0ebd42319611ef08101 Mon Sep 17 00:00:00 2001 From: Archer Lin Date: Mon, 8 Oct 2018 11:39:58 +0800 Subject: [PATCH] fix order & add link_to_list to journal show --- app/controllers/journals_controller.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index d43135c..2119cc7 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -4,7 +4,7 @@ class JournalsController < ApplicationController params = OrbitHelper.params categories = [] data = [] - journals = Journal.filter_by_categories.filter_by_tags.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + journals = Journal.order(created_at: :desc).filter_by_categories.filter_by_tags.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) ModuleApp.find_by(key: 'journal').categories.each do |e| categories << [e.id.to_s, e.title] end @@ -71,7 +71,7 @@ class JournalsController < ApplicationController def show_list params = OrbitHelper.params journal = Journal.find_by(uid: params[:uid]) - chapters = Chapter.where(journal_id: journal.id).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + chapters = Chapter.where(journal_id: journal.id).order(sort_number: :asc).page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) data = [] chapters.each do |node| data << { @@ -128,10 +128,12 @@ class JournalsController < ApplicationController "author_title" => t('journal.author'), "cover" => journal.cover.url, "cover_title" => t('journal.cover'), - "pub_date" => journal.pub_date, + "pub_date" => journal.pub_date.strftime('%Y-%m-%d'), "pub_date_title" => t('journal.pub_date'), "pub_information" => journal.pub_information, "pub_information_title" => t('journal.pub_information'), + link_to_list: OrbitHelper.url_to_show("#{journal.to_param}?mode=many"), + "extras" => { "mode" => "journal" }