From 4e3a86469d0acd4cc5b22307bd68b398cf9b44f4 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 6 Jun 2014 19:14:59 +0800 Subject: [PATCH] Fix frontend display order --- app/controllers/web_resources_controller.rb | 4 ++-- app/models/web_link.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/web_resources_controller.rb b/app/controllers/web_resources_controller.rb index e5e8e8b..467eccc 100644 --- a/app/controllers/web_resources_controller.rb +++ b/app/controllers/web_resources_controller.rb @@ -1,7 +1,7 @@ class WebResourcesController < ApplicationController def index - links = WebLink.order_by(:created_at=>'desc').filter_by_categories + links = WebLink.can_display.filter_by_categories web_link = links.collect do |link| statuses = link.statuses.collect do |status| { @@ -23,7 +23,7 @@ class WebResourcesController < ApplicationController end def widget - links = WebLink.order_by(:created_at=>'desc').filter_by_widget_categories + links = WebLink.can_display.filter_by_widget_categories web_link = links.collect do |link| statuses = link.statuses.collect do |status| { diff --git a/app/models/web_link.rb b/app/models/web_link.rb index 54db767..f6613a1 100644 --- a/app/models/web_link.rb +++ b/app/models/web_link.rb @@ -15,7 +15,7 @@ class WebLink field :create_user_id field :update_user_id - scope :can_display, ->{where(is_hidden: false).order_by([:is_top, :desc])} + scope :can_display, ->{where(is_hidden: false).order_by([:is_top,:desc],[:created_at,:desc])} before_save :add_http