From 27fda1f93860dd4688f3b59e42504e6844d1dbee Mon Sep 17 00:00:00 2001 From: nwb Date: Mon, 21 Jul 2014 16:19:45 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=9E=E8=B5=9B=E9=A6=96=E9=A1=B5=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/contests_controller.rb | 4 ++++ app/controllers/welcome_controller.rb | 7 ++++++- config/routes.rb | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/controllers/contests_controller.rb b/app/controllers/contests_controller.rb index 456aa7b4a..350204fbe 100644 --- a/app/controllers/contests_controller.rb +++ b/app/controllers/contests_controller.rb @@ -77,6 +77,10 @@ class ContestsController < ApplicationController end end + def search + redirect_to action: 'index',name:params[:name] + end + def homework @offset, @limit = api_offset_and_limit({:limit => 10}) @bids = @course.homeworks.order('deadline DESC') diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 27d02d56e..9330d1d44 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -118,6 +118,11 @@ class WelcomeController < ApplicationController search_condition = params[:q] search_type = params[:search_type].to_sym unless search_condition.blank? + if search_type.nil? && params[:contests_search] && params[:name] != "" + search_type = :contests + search_condition = params[:name] + end + respond_to do |format| format.html{ case search_type @@ -127,7 +132,7 @@ class WelcomeController < ApplicationController when :courses redirect_to courses_search_path(:name => search_condition) when :contests - redirect_to contests_search_path(:name => search_condition) + redirect_to contests_path(:name => search_condition) when :users redirect_to users_search_path(:name => search_condition) when :users_teacher diff --git a/config/routes.rb b/config/routes.rb index 780c8b77a..f7c679560 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -578,6 +578,7 @@ RedmineApp::Application.routes.draw do end match 'courses/search', :to => 'courses#search' + match '/contests/search', :controller => 'contests', :action => 'search', :via => [:get, :post] # add by nwb # 课程路由设置 resources :courses do