我已經爲我的應用程序(書籍類)添加了一個搜索功能,沒有路線匹配{:action =>「search」,:controller =>「devise/books」}
<%= form_tag url_for(:controller => 'books', :action => 'search'), :method => 'get' do %>
<label>Search</label>
<%= text_field_tag :search, params[:search], :id => 'search_field' %>
<%= submit_tag "Search", :name => nil %>
<% end %>
我也修改了相應的routes.rb:
Rails.application.routes.draw do
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" }
resources :users
resources :reviews
resources :books
root :to => "books#index"
match '/search', to: 'books#search', via: :get
現在,當我點擊搜索按鈕,我得到以下錯誤:
No route matches {:action=>"search", :controller=>"devise/books"}
提取的源(左右線#1):
1 <%= form_tag url_for(:controller => 'books', :action => 'search'), :method => 'get' do %>
不知道爲什麼Rails是尋找一個控制器稱爲色器件/這裏的書籍。任何幫助提前感謝和感謝。
斯拉夫科
這給了相同的結果。 – user3570192