Ruby on rails ruby on rails中的搜索页面路由错误

Ruby on rails ruby on rails中的搜索页面路由错误,ruby-on-rails,Ruby On Rails,我有一个搜索页面和一个搜索按钮,当我点击搜索按钮时,它给了我一个错误,如下所示: No route matches [POST] "/searching" 我希望当我点击搜索按钮时,它进入搜索页面,并显示搜索结果。以下是搜索页面控制器: def search @students=Students.all @blah = params[:tf_Zip] puts @blah if ( !params[:tf_Zip].blank? or params[

我有一个搜索页面和一个搜索按钮,当我点击搜索按钮时,它给了我一个错误,如下所示:

No route matches [POST] "/searching"
我希望当我点击搜索按钮时,它进入搜索页面,并显示搜索结果。以下是搜索页面控制器:

def search
    @students=Students.all
        @blah = params[:tf_Zip]
      puts @blah
    if ( !params[:tf_Zip].blank? or params[:tf_Zip] !="" )
       @user_zip = User.where(user_Zip: params[:tf_zip])
    end     
        render 'search'
  end 
您可以看到上面我在这里呈现到搜索页面,下面是routes.rb页面:

resources :search, only: [:search, :create]
match '/searching',  to: 'search#search',          via: 'get'
以下是耙道:

Helper  HTTP Verb   Path    Controller#Action
Path / Url          
search_new_path     GET     /search/new(.:format)   search#new
search_create_path  GET     /search/create(.:format)    search#create
settings_new_path   GET     /settings/new(.:format)     settings#new
educations_create_path  GET     /educations/create(.:format)    educations#create
educations_destroy_path     GET     /educations/destroy(.:format)   educations#destroy
professions_create_path     GET     /professions/create(.:format)   professions#create
professions_destroy_path    GET     /professions/destroy(.:format)  professions#destroy
communications_create_path  GET     /communications/create(.:format)    communications#create
communications_destroy_path     GET     /communications/destroy(.:format)   communications#destroy
availabilities_create_path  GET     /availabilities/create(.:format)    availabilities#create
availabilities_destroy_path     GET     /availabilities/destroy(.:format)   availabilities#destroy
users_path  GET     /users(.:format)    users#index
    POST    /users(.:format)    users#create
new_user_path   GET     /users/new(.:format)    users#new
edit_user_path  GET     /users/:id/edit(.:format)   users#edit
user_path   GET     /users/:id(.:format)    users#show
    PATCH   /users/:id(.:format)    users#update
    PUT     /users/:id(.:format)    users#update
    DELETE  /users/:id(.:format)    users#destroy
sessions_path   POST    /sessions(.:format)     sessions#create
new_session_path    GET     /sessions/new(.:format)     sessions#new
session_path    DELETE  /sessions/:id(.:format)     sessions#destroy
availabilities_path     POST    /availabilities(.:format)   availabilities#create
availability_path   DELETE  /availabilities/:id(.:format)   availabilities#destroy
communications_path     POST    /communications(.:format)   communications#create
communication_path  DELETE  /communications/:id(.:format)   communications#destroy
professions_path    POST    /professions(.:format)  professions#create
profession_path     DELETE  /professions/:id(.:format)  professions#destroy
educations_path     POST    /educations(.:format)   educations#create
education_path  DELETE  /educations/:id(.:format)   educations#destroy
settings_path   POST    /settings(.:format)     settings#create
new_setting_path    GET     /settings/new(.:format)     settings#new
search_index_path   POST    /search(.:format)   search#create
root_path   GET     /   static_pages#home
signup_path     GET     /signup(.:format)   users#new
signin_path     GET     /signin(.:format)   sessions#new
signout_path    DELETE  /signout(.:format)  sessions#destroy
default_path    GET     /default(.:format)  static_pages#default
    GET     /availabilities(.:format)   availabilities#new
    GET     /communications(.:format)   communications#new
    GET     /professions(.:format)  professions#new
    GET     /educations(.:format)   educations#new
    GET     /settings(.:format)     settings#new
searching_path  GET     /searching(.:format)    search#search 

请帮助我,等待你的答复。谢谢

试试这张,因为您正在用POST发送表单

match '/searching',  to: 'search#search', via: 'post'