所以我在使用我的導軌路由時出現了一個奇怪的問題,當我轉到應用程序索引路徑時它很好,但是如果索引路徑有任何路徑不起作用。我有一個控制器,它看起來像:帶有參數的網址導致請求被路由到錯誤的動作
class ThingsController < ApplicationController
def index
@things = Thing.search params[:q]
end
def show
@thing = Thing.find params[:id]
end
end
在我看來相當通用的搜索方法將:q
PARAM作爲其輸入,這裏是我的路線:
MyApp::Application.routes.draw do
root :to => "things#index"
resources :things
end
任何思考一下爲什麼這個正在發生?
我注意到在嘗試播放'root'指令的路徑時,資源和'root'共享同一個控制器的東西非常相似。看到我的問題在這裏:http://stackoverflow.com/questions/6313905/rails-3-problem-with-routes-constraint我發誓這是一個錯誤。我應該更新我的實際解決方案,但基本上我已經完成了所有路徑的硬編碼,因爲大約有20個,我想我可以擺脫它。 – Dex
@Dex,yah男人這很奇怪我想我現在不得不用你的方法來解決這個問題。謝謝。 –