From ea7ddc53392ec693e9316489fd34afe8f544932c Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 11 Apr 2016 19:27:06 +0800 Subject: [PATCH] added scope for index --- ...ersonal_technology_transfers_controller.rb | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/controllers/personal_technology_transfers_controller.rb b/app/controllers/personal_technology_transfers_controller.rb index 47cae25..f2d9a81 100644 --- a/app/controllers/personal_technology_transfers_controller.rb +++ b/app/controllers/personal_technology_transfers_controller.rb @@ -1,7 +1,7 @@ class PersonalTechnologyTransfersController < ApplicationController def index params = OrbitHelper.params - tts = TechnologyTransfer.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + tts = TechnologyTransfer.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue [] if fields_to_show.blank? @@ -22,17 +22,17 @@ class PersonalTechnologyTransfersController < ApplicationController t = [] fields_to_show.each do |fs| case fs - when "title" - t << {"value" => "" + (tt.send(fs) rescue "") + ""} - when "category" - t << {"value" => (tt.send("technology_transfer_category").title rescue "")} - when "authors" - t << {"value" => (tt.send(:member_profile).name rescue "")} - when "patent_granted" - t << {"value" => (tt.patent_granted ? t("personal_technology_transfer.y_es") : t("personal_technology_transfer.n_o"))} - else - t << {"value" => (tt.send(fs) rescue "")} - end + when "title" + t << {"value" => "" + (tt.send(fs) rescue "") + ""} + when "category" + t << {"value" => (tt.send("technology_transfer_category").title rescue "")} + when "authors" + t << {"value" => (tt.send(:member_profile).name rescue "")} + when "patent_granted" + t << {"value" => (tt.patent_granted ? t("personal_technology_transfer.y_es") : t("personal_technology_transfer.n_o"))} + else + t << {"value" => (tt.send(fs) rescue "")} + end end tts_list << {"technology_transfers" => t} end