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