我試圖使用meta_search全局搜索和模型搜索。路由問題的Rails 3
用於模型搜索,位於模型的索引文件中。我用這段代碼創建一個form_for。
<%= form_for @search, :url => building_path, :html => {:method => :get} do |f| %>
<%= f.label :name %>
<%= f.text_field :city %>
<%= f.submit %>
<% end %>
我的模型控制器有這樣的代碼
def index
@search = Building.search(params[:search])
@buildings = @search.all
end
但是,當我試圖表明該指數爲我建設,我有這個錯誤信息
ActionController::RoutingError in Buildings#index
Showing /Users/stephanebaribeau/Sites/cadifice/app/views/buildings/index.html.erb where line #4 raised:
No route matches {:action=>"show", :controller=>"buildings"}
Extracted source (around line #4):
1: <h1>Listing buildings</h1>
2:
3:
4: <%= form_for @search, :url => building_path, :html => {:method => :get} do |f| %>
5: <%= f.label :name %>
6: <%= f.text_field :city %>
7: <%= f.submit %>
我的routes.rb有這 資源:建築做 資源:地板 結束
我嘗試過沒有多少,同樣的錯誤。
我耙路線給我
building_floors GET /buildings/:building_id/floors(.:format) {:controller=>"floors", :action=>"index"}
POST /buildings/:building_id/floors(.:format) {:controller=>"floors", :action=>"create"}
new_building_floor GET /buildings/:building_id/floors/new(.:format) {:controller=>"floors", :action=>"new"}
edit_building_floor GET /buildings/:building_id/floors/:id/edit(.:format) {:controller=>"floors", :action=>"edit"}
building_floor GET /buildings/:building_id/floors/:id(.:format) {:controller=>"floors", :action=>"show"}
PUT /buildings/:building_id/floors/:id(.:format) {:controller=>"floors", :action=>"update"}
DELETE /buildings/:building_id/floors/:id(.:format) {:controller=>"floors", :action=>"destroy"}
buildings GET /buildings(.:format) {:controller=>"buildings", :action=>"index"}
POST /buildings(.:format) {:controller=>"buildings", :action=>"create"}
new_building GET /buildings/new(.:format) {:controller=>"buildings", :action=>"new"}
edit_building GET /buildings/:id/edit(.:format) {:controller=>"buildings", :action=>"edit"}
building GET /buildings/:id(.:format) {:controller=>"buildings", :action=>"show"}
PUT /buildings/:id(.:format) {:controller=>"buildings", :action=>"update"}
DELETE /buildings/:id(.:format) {:controller=>"buildings", :action=>"destroy"}
什麼錯我的路線? 感謝
我試過太多,同樣的路線錯誤。 – neimad