1
我有我的模型torubles。 我的代碼:Rails模型驗證 - validates_inclusion_of
class Typeofaid < ActiveRecord::Base
validates_inclusion_of :type, :in => %w(Food Water Health)
end
但每當我在框中鍵入「食品」等我拿到
`1 error prohibited this typeofaid from being saved:
* Type is not included in the list
`
誰能幫助?
做工精細,我有一個在這個問題:http://stackoverflow.com/q/435678/860536 – flooooo
那麼究竟是什麼我必須改變嗎? – Sean
食物,水,健康孩子類的「typeofaid」或只是字符串值?如果它們是字符串值,只需將屬性名稱從類型更改爲不同的名稱 - 可能是名稱。 – flooooo