我有一个搜索页面和一个搜索按钮,当我点击搜索按钮时,它在下面给了我一个错误:
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 :(得分:0)
试试这个,因为您正在发送带有POST的表单
match '/searching', to: 'search#search', via: 'post'