3
# ==Schema Information
# Schema version:
# Table name: terms
# id :integer not null, primary key
...
# user_id :integer
# term_type :string(255)`
term.rb:Rails 3的模型驗證列入不起作用
class Term < ActiveRecord::Base
validates :term_type, :inclusion => { :in => %w(Term Segment Entity Abbreviation) }`
的Rails 3.0.3,1.8.7紅寶石時,Windows通過Cygwin 驗證似乎不工作,即它接受term_type的任何值。 使用包含(或生成相同失敗條件的validates_inclusion_of)時,是否需要與模型中的數據匹配的數據庫驗證? 字符串的任何問題我應該警惕嗎?
Term_type只是DB中的一個字符串,而不是一個單獨的表。
任何指針非常讚賞。
文斯