sort added on created at desc

This commit is contained in:
Harry Bomrah 2015-11-16 17:53:54 +08:00
parent 7ebdf7c3d7
commit b5cda21304
2 changed files with 3 additions and 3 deletions

View File

@ -13,7 +13,7 @@ class AdBannersController < ApplicationController
def image_widget(adbanner)
images = []
adbanner.ad_images.can_display.each_with_index do |b,i|
adbanner.ad_images.can_display.desc(:created_at).each_with_index do |b,i|
if b.language_enabled.include?(I18n.locale.to_s)
image_link = OrbitHelper.is_mobile_view ? b.file.mobile.url : b.file.url
klass = i == 0 ? "active" : ""

View File

@ -240,7 +240,7 @@
data-cycle-timeout="5000"
>
<% 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| %>
<% if image.exchange_item == '1' %>
<div class="slide-img" style=" background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;"></div>
<% elsif image.exchange_item == '2' %>
@ -300,7 +300,7 @@
<a href="<%= new_admin_ad_image_path(banner: banner.id.to_s) %>" class="ad-image-new-btn">
<i class="icon-plus"></i> <%= t("new_image") %>
</a>
<% banner.ad_images.each_with_index do |image,idx| %>
<% banner.ad_images.desc(:created_at).each_with_index do |image,idx| %>
<div class="ad-banner-image-wrap">
<% if image.exchange_item == '1' %>
<div class="ad-banner-image <%= image.expired? ? "grayscale" : "" %>" style="background: url('<%= image.file.thumb.url %>'); background-size: cover; background-position: center;">