我这个型号:
class Bunny < ActiveRecord::Base
attr_accessor :number
validates_presence_of :number
validates_numericality_of :number
end
每当我提交表单来创建此模型时,我都会收到以下错误:
#的未定义方法“”0x103624338>
我通过将此方法添加到我的兔子模型中解决了这个问题:
def number_before_type_cast
number
end
我不喜欢它,但我想它会起作用,直到有人发布更好的解决方案。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)