From 52c12560ef8bb78fb3a3b1e2bfbb2b2e9295218e Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 16 Nov 2015 21:47:27 +0800 Subject: [PATCH] sort fixes and edit fix --- app/controllers/admin/universal_tables_controller.rb | 6 +++--- app/controllers/universal_tables_controller.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb index 3930039..e231d0e 100644 --- a/app/controllers/admin/universal_tables_controller.rb +++ b/app/controllers/admin/universal_tables_controller.rb @@ -15,7 +15,7 @@ class Admin::UniversalTablesController < OrbitAdminController if !@table.nil? @columns = @table.table_columns.asc(:order) @table_fields = @columns.collect{|tc| tc.title} - @entries = @table.table_entries.page(params[:page_id]).per(10) + @entries = @table.table_entries.desc(:created_at).page(params[:page_id]).per(10) end end @@ -37,8 +37,8 @@ class Admin::UniversalTablesController < OrbitAdminController end def edit_entry - id = params[:universal_table_id] - @entry = TableEntry.find(id) + id = params[:universal_table_id].split("-").last + @entry = TableEntry.where(:uid => id).first @table = @entry.u_table if !@table.nil? @columns = @table.table_columns.asc(:order) diff --git a/app/controllers/universal_tables_controller.rb b/app/controllers/universal_tables_controller.rb index 3fd18a0..4607ef1 100644 --- a/app/controllers/universal_tables_controller.rb +++ b/app/controllers/universal_tables_controller.rb @@ -39,9 +39,10 @@ class UniversalTablesController < ApplicationController columns.each do |column| entries << column.table_entry end + entries = entries.sort{|k,v| v["created_at"] <=> k["created_at"]} entries = Kaminari.paginate_array(entries).page(params["page_no"]).per(OrbitHelper.page_data_count) else - entries = table.table_entries.page(params["page_no"]).per(OrbitHelper.page_data_count) + entries = table.table_entries.desc(:created_at).page(params["page_no"]).per(OrbitHelper.page_data_count) end entries.each do |te| cols = []