From cc738edf2fc306b2b1ece387d22b629e42cee362 Mon Sep 17 00:00:00 2001 From: Wen Date: Thu, 24 Apr 2014 08:58:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=A6=E6=A0=A1=E5=88=97=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E4=BA=86=E6=90=9C=E7=B4=A2=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/school_controller.rb | 11 ++++++++++ app/views/school/index.html.erb | 31 +++++++++++++++++++++++----- config/routes.rb | 3 +++ 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb index a2f6a348..3e12ba3b 100644 --- a/app/controllers/school_controller.rb +++ b/app/controllers/school_controller.rb @@ -31,4 +31,15 @@ class SchoolController < ApplicationController render :text => options end + + def search_school + @school = School.where("province = ? AND name LIKE '%"+params[:key_word]+"%'", params[:province]); + + options = "" + @school.each do |s| + options << "
  • #{s.name}
  • " + end + + render :text => options + end end diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index ad952302..1277c0b4 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -22,17 +22,38 @@ location.href = "welcome/index?course.trustie.net&school_id="+id; } +

    全部学校

    -

    - 请选择省份:<%= select_tag "province", - options_from_collection_for_select(School.find_by_sql("select distinct province from schools"), :province, :province), - :onclick => "get_school(this.value)" %> -

    + +