From 4c1a1ec02f4c9865e7aadd0381fe1c185ae175f6 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 16 Nov 2015 17:54:33 +0800 Subject: [PATCH] added sort on created_at desc --- app/controllers/ad_banners_controller.rb | 2 +- app/views/admin/ad_banners/_index.html.erb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/ad_banners_controller.rb b/app/controllers/ad_banners_controller.rb index 6fc34fb..08fdca7 100644 --- a/app/controllers/ad_banners_controller.rb +++ b/app/controllers/ad_banners_controller.rb @@ -1,7 +1,7 @@ class AdBannersController < ApplicationController def widget adbanner = Banner.find(OrbitHelper.widget_custom_value) - images = adbanner.ad_images.can_display.collect.with_index do |b,i| + images = adbanner.ad_images.can_display.desc(:created_at).collect.with_index do |b,i| image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url klass = i == 0 ? "active" : "" caption = i == 0 ? '
' : "" diff --git a/app/views/admin/ad_banners/_index.html.erb b/app/views/admin/ad_banners/_index.html.erb index 6f41a91..a1631ec 100644 --- a/app/views/admin/ad_banners/_index.html.erb +++ b/app/views/admin/ad_banners/_index.html.erb @@ -222,7 +222,7 @@ data-cycle-timeout="<%= banner.timeout.to_i*1000 %>" > <% if !banner.ad_images.can_display.blank? %> - <% banner.ad_images.can_display.each do |image| %> + <% banner.ad_images.can_display.desc(:created_at).each do |image| %>
<% end %> <% else %> @@ -283,7 +283,7 @@ <%= t("ad.new_image") %> - <% banner.ad_images.each_with_index do |image,idx| %> + <% banner.ad_images.desc(:created_at).each_with_index do |image,idx| %>
" style="background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"> <% if image.expired? %>