2
我要顯示這樣的:在Rails 3中,如何在使用驗證錯誤時顯示錯誤的值?
validates :field, :inclusion => { :in => fields, :message => "is not allowed: {self.field}"}
但自指的是類本身,而不是實例變量。
我要顯示這樣的:在Rails 3中,如何在使用驗證錯誤時顯示錯誤的值?
validates :field, :inclusion => { :in => fields, :message => "is not allowed: {self.field}"}
但自指的是類本身,而不是實例變量。
如果我理解正確的話,你要像
class Coffee < ActiveRecord::Base
validates_inclusion_of :size, :in => %w(small medium large),
:message => "%{value} is not a valid size"
end