From 1e55555f8415b886c473cfad55549138eeca4bed Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 19 Aug 2019 16:36:18 +0800 Subject: [PATCH] Update personal_projects_controller.rb fix coding style --- .../personal_projects_controller.rb | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/personal_projects_controller.rb b/app/controllers/personal_projects_controller.rb index 4c4245e..df64c36 100644 --- a/app/controllers/personal_projects_controller.rb +++ b/app/controllers/personal_projects_controller.rb @@ -1,12 +1,8 @@ class PersonalProjectsController < ApplicationController - def search_all_words(target,word) - target=target.upcase - words=word.upcase.split(' ') - return words.select{|value| target.include? value}==words - end def index params = OrbitHelper.params - projects = Project.where(:project_title.ne => nil,:project_title.ne => "").sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) + page_data_count = OrbitHelper.page_data_count + projects = Project.where(:project_title.ne => nil,:project_title.ne => "").sort_for_frontend.page(OrbitHelper.params[:page_no]).per(page_data_count) fields_to_show = Page.where(:page_id => params[:page_id]).first.custom_array_field rescue [] if fields_to_show.blank? fields_to_show = [ @@ -38,8 +34,8 @@ class PersonalProjectsController < ApplicationController else page_to_show = params[:page_no].to_i end - projects = projects_show[(page_to_show-1)*OrbitHelper.page_data_count...page_to_show*OrbitHelper.page_data_count] - projects_total_pages = (projects_show.length/OrbitHelper.page_data_count.to_f).ceil + projects = projects_show[(page_to_show-1)*page_data_count...page_to_show*page_data_count] + projects_total_pages = (projects_show.length/page_data_count.to_f).ceil else projects_total_pages = projects.total_pages end @@ -78,13 +74,13 @@ class PersonalProjectsController < ApplicationController choice_select=choice_value.map{|iter| iter==params[:selectbox] ? "selected" : ""} choice_select=choice_select.map{|value| {"choice_select" => value}} choice_value=choice_value.map{|value| {"choice_value" => value}} - choice_default = params[:locale]!='en' ? "——選取分類——" : "——select class——" + choice_default = t("personal_project.select_class") choice_show.unshift(choice_default) choice_show=choice_show.map{|value| {"choice_show" => value}} choice=choice_value.zip(choice_show,choice_select) choice=choice.map{|value| value.inject:merge} - select_text = params[:locale]!='en' ? "搜尋類別:" : "search class:" - search_text = params[:locale]!='en' ? "關鍵字搜尋:" : "word to search:" + select_text = t("personal_project.search_class") + search_text = t("personal_project.word_to_search") { "projects" => project_list, "headers" => headers, @@ -152,6 +148,11 @@ class PersonalProjectsController < ApplicationController page.save render :json => {"success" => true}.to_json end - +private + def search_all_words(target,word) + target=target.upcase + words=word.upcase.split(' ') + return words.select{|value| target.include? value}==words + end end