From 609a1c83ba93bb4570f1db1a35a31a1006de914b Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 15 Aug 2019 09:47:16 +0800 Subject: [PATCH] Update personal_conferences_controller.rb --- .../personal_conferences_controller.rb | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/app/controllers/personal_conferences_controller.rb b/app/controllers/personal_conferences_controller.rb index d086133..50536be 100644 --- a/app/controllers/personal_conferences_controller.rb +++ b/app/controllers/personal_conferences_controller.rb @@ -1,4 +1,9 @@ class PersonalConferencesController < 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 writing_conferences = WritingConference.where(:is_hidden=>false).sort_for_frontend.page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count) @@ -26,24 +31,24 @@ class PersonalConferencesController < ApplicationController case params[:selectbox] when "paper_title","default" if page.custom_string_field == "table" - writing_conferences_show = writing_conferences_temp.select {|value| value.paper_title.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.paper_title, params[:keywords])} else - writing_conferences_show = writing_conferences_temp.select {|value| value.create_link.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.create_link, params[:keywords])} end when "paper_levels" - writing_conferences_show = writing_conferences_temp.select {|value| value.conference_paper_levels.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_paper_levels.collect{|x| x.title}.join(', ').to_s, params[:keywords])} when "paper_types" - writing_conferences_show = writing_conferences_temp.select {|value| value.conference_paper_types.collect{|x| x.title}.join(', ').to_s.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_paper_types.collect{|x| x.title}.join(', ').to_s, params[:keywords])} when "period" - writing_conferences_show = writing_conferences_temp.select {|value| value.duration.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.duration.include? params[:keywords]} when "publication_date" - writing_conferences_show = writing_conferences_temp.select {|value| value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', ').include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.send("publication_date").strftime("%Y/%m").collect{|x| x.title}.join(', '), params[:keywords])} when "author_type" - writing_conferences_show = writing_conferences_temp.select {|value| value.conference_author_types.collect{|cat| cat.title}.join(", ").include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.conference_author_types.collect{|cat| cat.title}.join(", "), params[:keywords])} when "language" - writing_conferences_show = writing_conferences_temp.select {|value| (!value.language.nil? ? t("#{value.language}") : "").include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words((!value.language.nil? ? t("#{value.language}") : ""), params[:keywords])} else - writing_conferences_show = writing_conferences_temp.select {|value| value.send(params[:selectbox]).to_s.include? params[:keywords]} + writing_conferences_show = writing_conferences_temp.select {|value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords])} end if params[:page_no].nil? page_to_show = 1