2014-03-12 26 views
0

我有一個搜索頁面,並在其上的搜索按鈕,當我點擊搜索按鈕,它給了我一個錯誤如下:搜索頁面路由錯誤軌道上

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 

請幫助我,等待您的回覆。由於

回答

0

試試這一個,因爲你與POST

match '/searching', to: 'search#search', via: 'post' 
發送表單