开发者

Rails model validation not working

model:

validates :name, :presence =>开发者_如何学Go; true
validates :year, :presence => true
validates :description, :presence => true

when submitting the form containing these fields, leaving the text boxes blank on purpose, instead of getting the Rails error messaging, I get the following exception thrown:

NoMethodError

You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each

Any thoughts on why this may occur would be greatly appreciated.


A stab in the dark would be that its not your validations throwing the error message. My first instinct is that its the error view code (if you are looping through the errors the nil is possibly in there). Its also possible its an error in the controller but I would have to see the first couple lines of the backtrace to make a more informed guess.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜