【发布时间】:2012-05-28 12:29:08
【问题描述】:
我有一个模特代表
class Representative< ActiveRecord::Base
validates_inclusion_of :gender, :in => Representative.genders
def self.genders
%w(M F)
end
end
当我在性别函数定义之前编写验证行时,它不起作用,它给出了未定义的方法性别错误。当我在它起作用的函数下方编写验证时,为什么会发生这种情况?我习惯于调用和定义函数而不必担心顺序,我这里真的有什么问题吗?
谢谢
【问题讨论】:
标签: ruby-on-rails-3 validation activerecord