我正在經歷Sinatra項目的一些非常特殊的結果。ActiveRecord沒有正確讀取方法參數
一切工作正常,今天早上我開始在我的ActiveRecord調用中出現錯誤。
我的第一個電話是從我的國家表得到一個隨機行
這種失敗:
@randomCountry = Country.where("name != ?", @countryName).first(:order => "RANDOM()")
,出現以下錯誤:
can't convert Hash into Integer
如果我離開出:命令,我沒有得到一個錯誤,所以這個工程:
@randomCountry = Country.where("name != ?", @countryName).first()
但顯然是不理想的,因爲它不是隨機的!
那麼一點點再往下我得到一個完整的國家名單如下:
@countriesList = Country.find(:all, :order => "name")
這個錯誤有以下幾點:
Couldn't find all Countries with 'code': (all, {:order=>"name"}) (found 0 results, but was looking for 2)
如果我省略名字的順序:
@countriesList = Country.find(:all)
我得到這個錯誤:
Couldn't find Country with 'code'=all
我國有代碼一個主鍵,但我以前能夠在所有撥打這個電話沒有任何問題。
任何幫助,試圖調試這是非常讚賞,我可以發佈更多的細節,如果它是必需的。
尋找這裏:http://api.rubyonrails.org/classes/ActiveRecord/FinderMethods。 html#方法 - 我發現它看起來並不像以下所有對find方法的支持。你是在什麼版本的ActiveRecord? –